Simplified usages in UIX project

This commit is contained in:
Joshua Askharoun
2021-04-02 19:10:51 -05:00
parent 2b20ca46ad
commit c07b53bb0b
464 changed files with 14054 additions and 14064 deletions
+3 -3
View File
@@ -14,9 +14,9 @@ namespace Microsoft.Iris.Markup
public AliasMapping(string alias, LoadResult loadResult, string targetType)
{
this.Alias = alias;
this.LoadResult = loadResult;
this.TargetType = targetType;
Alias = alias;
LoadResult = loadResult;
TargetType = targetType;
}
}
}
@@ -20,19 +20,19 @@ namespace Microsoft.Iris.Markup
TypeSchema[] parameterTypes)
: base(owner)
{
this._constructorInfo = constructorInfo;
this._parameterTypes = parameterTypes;
_constructorInfo = constructorInfo;
_parameterTypes = parameterTypes;
}
public override TypeSchema[] ParameterTypes => this._parameterTypes;
public override TypeSchema[] ParameterTypes => _parameterTypes;
public override object Construct(object[] parameters)
{
object[] paramters = AssemblyLoadResult.UnwrapObjectList(parameters);
AssemblyTypeSchema owner = (AssemblyTypeSchema)this.Owner;
if (this._constructor == null)
this._constructor = ReflectionHelper.CreateMethodInvoke(_constructorInfo);
object instance = this._constructor(null, paramters);
AssemblyTypeSchema owner = (AssemblyTypeSchema)Owner;
if (_constructor == null)
_constructor = ReflectionHelper.CreateMethodInvoke(_constructorInfo);
object instance = _constructor(null, paramters);
return AssemblyLoadResult.WrapObject(owner, instance);
}
}
@@ -14,8 +14,8 @@ namespace Microsoft.Iris.Markup
public AssemblyEventSchema(AssemblyTypeSchema owner, EventInfo eventInfo)
: base(owner)
=> this._eventInfo = eventInfo;
=> _eventInfo = eventInfo;
public override string Name => this._eventInfo.Name;
public override string Name => _eventInfo.Name;
}
}
+12 -12
View File
@@ -165,13 +165,13 @@ namespace Microsoft.Iris.Markup
s_typeCache = null;
}
public string Namespace => this._namespace;
public string Namespace => _namespace;
public override LoadResultStatus Status => LoadResultStatus.Success;
public override TypeSchema FindType(string name)
{
Type type = this._assembly.GetType(this._namespacePrefix + name, false);
Type type = _assembly.GetType(_namespacePrefix + name, false);
if (type == null)
return null;
if (type.IsVisible)
@@ -315,16 +315,16 @@ namespace Microsoft.Iris.Markup
public override string GetCompilerReferenceName() => base.GetCompilerReferenceName() ?? string.Format("{0}{1}/{2}", "assembly://", _assembly.GetName().Name, _namespace);
internal Assembly Assembly => this._assembly;
internal Assembly Assembly => _assembly;
private AssemblyLoadResult(Assembly assembly, string ns, string uri)
: base(uri)
{
this._assembly = assembly;
this._namespace = ns;
_assembly = assembly;
_namespace = ns;
if (ns == null)
return;
this._namespacePrefix = ns + ".";
_namespacePrefix = ns + ".";
}
internal struct MapAssemblyKey
@@ -334,21 +334,21 @@ namespace Microsoft.Iris.Markup
public MapAssemblyKey(Assembly assembly, string ns)
{
this._assembly = assembly;
this._namespace = ns;
_assembly = assembly;
_namespace = ns;
}
public override bool Equals(object obj)
{
AssemblyLoadResult.MapAssemblyKey mapAssemblyKey = (AssemblyLoadResult.MapAssemblyKey)obj;
return this._assembly == mapAssemblyKey._assembly && this._namespace == mapAssemblyKey._namespace;
return _assembly == mapAssemblyKey._assembly && _namespace == mapAssemblyKey._namespace;
}
public override int GetHashCode()
{
int hashCode = this._assembly.GetHashCode();
if (this._namespace != null)
hashCode ^= this._namespace.GetHashCode();
int hashCode = _assembly.GetHashCode();
if (_namespace != null)
hashCode ^= _namespace.GetHashCode();
return hashCode;
}
}
@@ -15,47 +15,47 @@ namespace Microsoft.Iris.Markup
public AssemblyMarkupDataQuery(MarkupDataQuerySchema type, AssemblyDataProviderWrapper provider)
: base(type)
{
this._externalQuery = provider.ConstructQuery(type);
this._externalQuery.DeclareOwner(this);
this._externalQuery.SetInternalObject(this);
this.ApplyDefaultValues();
_externalQuery = provider.ConstructQuery(type);
_externalQuery.DeclareOwner(this);
_externalQuery.SetInternalObject(this);
ApplyDefaultValues();
}
public override void NotifyInitialized()
{
base.NotifyInitialized();
if (this._externalQuery == null)
if (_externalQuery == null)
return;
this._externalQuery.OnInitialize();
_externalQuery.OnInitialize();
}
protected override void OnDispose()
{
base.OnDispose();
if (this._externalQuery == null)
if (_externalQuery == null)
return;
this._externalQuery.Dispose(this);
_externalQuery.Dispose(this);
}
public override void Refresh() => this._externalQuery.Refresh();
public override void Refresh() => _externalQuery.Refresh();
public override object Result
{
get => AssemblyLoadResult.WrapObject(this._externalQuery.Result);
set => this._externalQuery.Result = AssemblyLoadResult.UnwrapObject(value);
get => AssemblyLoadResult.WrapObject(_externalQuery.Result);
set => _externalQuery.Result = AssemblyLoadResult.UnwrapObject(value);
}
public override DataProviderQueryStatus Status => this._externalQuery.Status;
public override DataProviderQueryStatus Status => _externalQuery.Status;
public override bool Enabled
{
get => this._externalQuery.Enabled;
set => this._externalQuery.Enabled = value;
get => _externalQuery.Enabled;
set => _externalQuery.Enabled = value;
}
protected override bool ExternalObjectGetProperty(string propertyName, out object value)
{
object property = this._externalQuery.GetProperty(propertyName);
object property = _externalQuery.GetProperty(propertyName);
value = AssemblyLoadResult.WrapObject(property);
return true;
}
@@ -63,7 +63,7 @@ namespace Microsoft.Iris.Markup
protected override bool ExternalObjectSetProperty(string propertyName, object value)
{
object obj = AssemblyLoadResult.UnwrapObject(value);
this._externalQuery.SetProperty(propertyName, obj);
_externalQuery.SetProperty(propertyName, obj);
return true;
}
@@ -14,11 +14,11 @@ namespace Microsoft.Iris.Markup
public AssemblyMarkupDataType(MarkupDataTypeSchema type, IDataProviderObject externalObject)
: base(type)
=> this._externalObject = externalObject;
=> _externalObject = externalObject;
protected override bool ExternalObjectGetProperty(string propertyName, out object value)
{
object property = this._externalObject.GetProperty(propertyName);
object property = _externalObject.GetProperty(propertyName);
value = AssemblyLoadResult.WrapObject(property);
return true;
}
@@ -26,7 +26,7 @@ namespace Microsoft.Iris.Markup
protected override bool ExternalObjectSetProperty(string propertyName, object value)
{
object obj = AssemblyLoadResult.UnwrapObject(value);
this._externalObject.SetProperty(propertyName, obj);
_externalObject.SetProperty(propertyName, obj);
return true;
}
@@ -21,26 +21,26 @@ namespace Microsoft.Iris.Markup
TypeSchema[] parameterTypes)
: base(owner)
{
this._methodInfo = methodInfo;
this._parameterTypes = parameterTypes;
this._returnTypeSchema = AssemblyLoadResult.MapType(this._methodInfo.ReturnType);
_methodInfo = methodInfo;
_parameterTypes = parameterTypes;
_returnTypeSchema = AssemblyLoadResult.MapType(_methodInfo.ReturnType);
}
public override string Name => this._methodInfo.Name;
public override string Name => _methodInfo.Name;
public override TypeSchema[] ParameterTypes => this._parameterTypes;
public override TypeSchema[] ParameterTypes => _parameterTypes;
public override TypeSchema ReturnType => this._returnTypeSchema;
public override TypeSchema ReturnType => _returnTypeSchema;
public override bool IsStatic => this._methodInfo.IsStatic;
public override bool IsStatic => _methodInfo.IsStatic;
public override object Invoke(object instance, object[] parameters)
{
object target = AssemblyLoadResult.UnwrapObject(instance);
object[] paramters = AssemblyLoadResult.UnwrapObjectList(parameters);
if (this._method == null)
this._method = ReflectionHelper.CreateMethodInvoke(_methodInfo);
return AssemblyLoadResult.WrapObject(this._returnTypeSchema, this._method(target, paramters));
if (_method == null)
_method = ReflectionHelper.CreateMethodInvoke(_methodInfo);
return AssemblyLoadResult.WrapObject(_returnTypeSchema, _method(target, paramters));
}
}
}
File diff suppressed because it is too large Load Diff
@@ -20,22 +20,22 @@ namespace Microsoft.Iris.Markup
public AssemblyPropertySchema(AssemblyTypeSchema owner, PropertyInfo propertyInfo)
: base(owner)
{
this._propertyInfo = propertyInfo;
this._propertyTypeSchema = AssemblyLoadResult.MapType(this._propertyInfo.PropertyType);
this._isStatic = (this._propertyInfo.GetGetMethod() ?? this._propertyInfo.GetSetMethod()).IsStatic;
_propertyInfo = propertyInfo;
_propertyTypeSchema = AssemblyLoadResult.MapType(_propertyInfo.PropertyType);
_isStatic = (_propertyInfo.GetGetMethod() ?? _propertyInfo.GetSetMethod()).IsStatic;
}
public override string Name => this._propertyInfo.Name;
public override string Name => _propertyInfo.Name;
public override TypeSchema PropertyType => this._propertyTypeSchema;
public override TypeSchema PropertyType => _propertyTypeSchema;
public override TypeSchema AlternateType => (TypeSchema)null;
public override bool CanRead => this._propertyInfo.CanRead;
public override bool CanRead => _propertyInfo.CanRead;
public override bool CanWrite => this._propertyInfo.CanWrite;
public override bool CanWrite => _propertyInfo.CanWrite;
public override bool IsStatic => this._isStatic;
public override bool IsStatic => _isStatic;
public override ExpressionRestriction ExpressionRestriction => ExpressionRestriction.None;
@@ -47,31 +47,31 @@ namespace Microsoft.Iris.Markup
{
get
{
AssemblyTypeSchema owner = (AssemblyTypeSchema)this.Owner;
return !this._isStatic && owner.NotifiesOnChange;
AssemblyTypeSchema owner = (AssemblyTypeSchema)Owner;
return !_isStatic && owner.NotifiesOnChange;
}
}
public override object GetValue(object instance)
{
object target = AssemblyLoadResult.UnwrapObject(instance);
if (this._getMethod == null)
this._getMethod = ReflectionHelper.CreateMethodInvoke(this._propertyInfo.GetGetMethod());
return AssemblyLoadResult.WrapObject(this._propertyTypeSchema, this._getMethod(target, null));
if (_getMethod == null)
_getMethod = ReflectionHelper.CreateMethodInvoke(_propertyInfo.GetGetMethod());
return AssemblyLoadResult.WrapObject(_propertyTypeSchema, _getMethod(target, null));
}
public override void SetValue(ref object instance, object value)
{
object target = AssemblyLoadResult.UnwrapObject(instance);
object obj1 = AssemblyLoadResult.UnwrapObject(value);
if (this._setMethod == null)
if (_setMethod == null)
{
this._setMethod = ReflectionHelper.CreateMethodInvoke(this._propertyInfo.GetSetMethod());
this._setMethodParams = new object[1];
_setMethod = ReflectionHelper.CreateMethodInvoke(_propertyInfo.GetSetMethod());
_setMethodParams = new object[1];
}
this._setMethodParams[0] = obj1;
object obj2 = this._setMethod(target, this._setMethodParams);
this._setMethodParams[0] = null;
_setMethodParams[0] = obj1;
object obj2 = _setMethod(target, _setMethodParams);
_setMethodParams[0] = null;
}
}
}
+60 -60
View File
@@ -29,23 +29,23 @@ namespace Microsoft.Iris.Markup
protected AssemblyTypeSchema(Type type, TypeSchema baseType)
: base(AssemblyLoadResult.MapAssembly(type.Assembly, type.Namespace))
{
this._type = type;
this._baseType = baseType;
this._isFrameworkEnum = type.IsEnum && Enum.GetUnderlyingType(type) == typeof(int);
this._notifiesOnChange = typeof(INotifyPropertyChanged).IsAssignableFrom(this._type);
this._isDisposable = typeof(IDisposable).IsAssignableFrom(this._type);
_type = type;
_baseType = baseType;
_isFrameworkEnum = type.IsEnum && Enum.GetUnderlyingType(type) == typeof(int);
_notifiesOnChange = typeof(INotifyPropertyChanged).IsAssignableFrom(_type);
_isDisposable = typeof(IDisposable).IsAssignableFrom(_type);
}
protected override void OnDispose()
{
base.OnDispose();
foreach (KeyValueEntry<MethodSignatureKey, ConstructorSchema> keyValueEntry in this._constructorCache)
foreach (KeyValueEntry<MethodSignatureKey, ConstructorSchema> keyValueEntry in _constructorCache)
keyValueEntry.Value.Dispose(this);
foreach (KeyValueEntry<string, PropertySchema> keyValueEntry in this._propertyCache)
foreach (KeyValueEntry<string, PropertySchema> keyValueEntry in _propertyCache)
keyValueEntry.Value.Dispose(this);
foreach (KeyValueEntry<MethodSignatureKey, MethodSchema> keyValueEntry in this._methodCache)
foreach (KeyValueEntry<MethodSignatureKey, MethodSchema> keyValueEntry in _methodCache)
keyValueEntry.Value.Dispose(this);
foreach (KeyValueEntry<string, EventSchema> keyValueEntry in this._eventCache)
foreach (KeyValueEntry<string, EventSchema> keyValueEntry in _eventCache)
keyValueEntry.Value.Dispose(this);
}
@@ -53,9 +53,9 @@ namespace Microsoft.Iris.Markup
{
get
{
string str = this._type.Name;
if (this._type.IsGenericType)
str = this._type.ToString().Substring(((AssemblyLoadResult)this.Owner).Namespace.Length + 1);
string str = _type.Name;
if (_type.IsGenericType)
str = _type.ToString().Substring(((AssemblyLoadResult)Owner).Namespace.Length + 1);
return str;
}
}
@@ -66,38 +66,38 @@ namespace Microsoft.Iris.Markup
{
get
{
if (this._baseType == null && this != AssemblyLoadResult.ObjectTypeSchema)
if (_baseType == null && this != AssemblyLoadResult.ObjectTypeSchema)
{
if (this._type.BaseType != null)
this._baseType = AssemblyLoadResult.MapType(this._type.BaseType);
else if (this._type.IsInterface)
this._baseType = AssemblyLoadResult.ObjectTypeSchema;
if (_type.BaseType != null)
_baseType = AssemblyLoadResult.MapType(_type.BaseType);
else if (_type.IsInterface)
_baseType = AssemblyLoadResult.ObjectTypeSchema;
}
return this._baseType;
return _baseType;
}
}
public override bool Contractual => this._type.IsInterface;
public override bool Contractual => _type.IsInterface;
public override Type RuntimeType => this._type;
public override Type RuntimeType => _type;
public Type InternalType => this._type;
public Type InternalType => _type;
public override bool IsNativeAssignableFrom(object check) => this.InternalType.IsAssignableFrom(AssemblyLoadResult.UnwrapObject(check).GetType());
public override bool IsNativeAssignableFrom(object check) => InternalType.IsAssignableFrom(AssemblyLoadResult.UnwrapObject(check).GetType());
public override bool IsNativeAssignableFrom(TypeSchema checkSchema)
{
Type c = checkSchema.RuntimeType;
if (checkSchema is AssemblyTypeSchema assemblyTypeSchema)
c = assemblyTypeSchema.InternalType;
return this.InternalType.IsAssignableFrom(c);
return InternalType.IsAssignableFrom(c);
}
public override bool Disposable => this._isDisposable;
public override bool Disposable => _isDisposable;
public override object ConstructDefault() => AssemblyLoadResult.WrapObject(this, Activator.CreateInstance(this._type));
public override object ConstructDefault() => AssemblyLoadResult.WrapObject(this, Activator.CreateInstance(_type));
public override bool HasDefaultConstructor => this._type.IsValueType || this._type.GetConstructor(Type.EmptyTypes) != null;
public override bool HasDefaultConstructor => _type.IsValueType || _type.GetConstructor(Type.EmptyTypes) != null;
public override bool HasInitializer => false;
@@ -108,23 +108,23 @@ namespace Microsoft.Iris.Markup
public override ConstructorSchema FindConstructor(TypeSchema[] parameters)
{
ConstructorSchema constructorSchema;
if (!this._constructorCache.TryGetValue(new MethodSignatureKey(parameters), out constructorSchema))
if (!_constructorCache.TryGetValue(new MethodSignatureKey(parameters), out constructorSchema))
{
ConstructorInfo[] constructors;
if (!this.s_constructorInfosCache.TryGetValue(this._type, out constructors))
if (!s_constructorInfosCache.TryGetValue(_type, out constructors))
{
constructors = this._type.GetConstructors(BindingFlags.Instance | BindingFlags.Public);
this.s_constructorInfosCache[this._type] = constructors;
constructors = _type.GetConstructors(BindingFlags.Instance | BindingFlags.Public);
s_constructorInfosCache[_type] = constructors;
}
if (constructors != null)
{
foreach (ConstructorInfo constructorInfo in constructors)
{
TypeSchema[] schemaParameters = null;
if (this.CheckForMethodSignatureMatch(constructorInfo, null, parameters, out schemaParameters))
if (CheckForMethodSignatureMatch(constructorInfo, null, parameters, out schemaParameters))
{
constructorSchema = new AssemblyConstructorSchema(this, constructorInfo, schemaParameters);
this._constructorCache[new MethodSignatureKey(schemaParameters)] = constructorSchema;
_constructorCache[new MethodSignatureKey(schemaParameters)] = constructorSchema;
break;
}
}
@@ -136,13 +136,13 @@ namespace Microsoft.Iris.Markup
public override PropertySchema FindProperty(string name)
{
PropertySchema propertySchema;
if (!this._propertyCache.TryGetValue(name, out propertySchema))
if (!_propertyCache.TryGetValue(name, out propertySchema))
{
PropertyInfo propertyHelper = GetPropertyHelper(this._type, name);
PropertyInfo propertyHelper = GetPropertyHelper(_type, name);
if (propertyHelper != null)
{
propertySchema = new AssemblyPropertySchema(this, propertyHelper);
this._propertyCache[name] = propertySchema;
_propertyCache[name] = propertySchema;
}
}
return propertySchema;
@@ -182,23 +182,23 @@ namespace Microsoft.Iris.Markup
public override MethodSchema FindMethod(string name, TypeSchema[] parameters)
{
MethodSchema methodSchema;
if (!this._methodCache.TryGetValue(new MethodSignatureKey(name, parameters), out methodSchema))
if (!_methodCache.TryGetValue(new MethodSignatureKey(name, parameters), out methodSchema))
{
MethodInfo[] methodInfoArray = null;
if (!this.s_methodInfosCache.TryGetValue(this._type, out methodInfoArray))
if (!s_methodInfosCache.TryGetValue(_type, out methodInfoArray))
{
methodInfoArray = this._type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
this.s_methodInfosCache[this._type] = methodInfoArray;
methodInfoArray = _type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
s_methodInfosCache[_type] = methodInfoArray;
}
if (methodInfoArray != null)
{
foreach (MethodInfo methodInfo in methodInfoArray)
{
TypeSchema[] schemaParameters;
if (this.CheckForMethodSignatureMatch(methodInfo, name, parameters, out schemaParameters))
if (CheckForMethodSignatureMatch(methodInfo, name, parameters, out schemaParameters))
{
methodSchema = new AssemblyMethodSchema(this, methodInfo, schemaParameters);
this._methodCache[new MethodSignatureKey(name, schemaParameters)] = methodSchema;
_methodCache[new MethodSignatureKey(name, schemaParameters)] = methodSchema;
break;
}
}
@@ -233,13 +233,13 @@ namespace Microsoft.Iris.Markup
public override EventSchema FindEvent(string name)
{
EventSchema eventSchema;
if (!this._eventCache.TryGetValue(name, out eventSchema))
if (!_eventCache.TryGetValue(name, out eventSchema))
{
EventInfo eventInfo = this._type.GetEvent(name);
EventInfo eventInfo = _type.GetEvent(name);
if (eventInfo != null)
{
eventSchema = new AssemblyEventSchema(this, eventInfo);
this._eventCache[name] = eventSchema;
_eventCache[name] = eventSchema;
}
}
return eventSchema;
@@ -247,11 +247,11 @@ namespace Microsoft.Iris.Markup
public override object FindCanonicalInstance(string name)
{
if (this._type.IsEnum)
if (_type.IsEnum)
{
try
{
return Enum.Parse(this._type, name);
return Enum.Parse(_type, name);
}
catch (ArgumentException ex)
{
@@ -267,26 +267,26 @@ namespace Microsoft.Iris.Markup
TypeSchema fromType,
out object instance)
{
if (this._isFrameworkEnum && Int32Schema.Type.IsAssignableFrom(fromType))
if (_isFrameworkEnum && Int32Schema.Type.IsAssignableFrom(fromType))
{
instance = Enum.ToObject(this._type, (int)from);
instance = Enum.ToObject(_type, (int)from);
return Result.Success;
}
instance = null;
return Result.Fail("Unimplemented");
}
public override bool SupportsTypeConversion(TypeSchema fromType) => this._isFrameworkEnum && Int32Schema.Type.IsAssignableFrom(fromType);
public override bool SupportsTypeConversion(TypeSchema fromType) => _isFrameworkEnum && Int32Schema.Type.IsAssignableFrom(fromType);
public override void EncodeBinary(ByteCodeWriter writer, object instance)
{
if (this._type.IsEnum)
if (_type.IsEnum)
{
writer.WriteInt32((int)instance);
}
else
{
if (this._type != typeof(Guid))
if (_type != typeof(Guid))
return;
writer.Write(((Guid)instance).ToByteArray(), 16U);
}
@@ -295,9 +295,9 @@ namespace Microsoft.Iris.Markup
public override object DecodeBinary(ByteCodeReader reader)
{
object obj;
if (this._type.IsEnum)
obj = Enum.ToObject(this._type, reader.ReadInt32());
else if (this._type == typeof(Guid))
if (_type.IsEnum)
obj = Enum.ToObject(_type, reader.ReadInt32());
else if (_type == typeof(Guid))
{
byte[] b = new byte[16];
for (int index = 0; index < 16; ++index)
@@ -313,9 +313,9 @@ namespace Microsoft.Iris.Markup
{
get
{
if (this._type == typeof(Guid))
if (_type == typeof(Guid))
return true;
return this._type.IsEnum && Enum.GetUnderlyingType(this._type) == typeof(int);
return _type.IsEnum && Enum.GetUnderlyingType(_type) == typeof(int);
}
}
@@ -327,14 +327,14 @@ namespace Microsoft.Iris.Markup
public override bool SupportsOperation(OperationType op) => op == OperationType.RelationalEquals || op == OperationType.RelationalNotEquals;
public override bool IsNullAssignable => !this._type.IsValueType;
public override bool IsNullAssignable => !_type.IsValueType;
public override int FindTypeHint => -1;
public bool NotifiesOnChange => this._notifiesOnChange;
public bool NotifiesOnChange => _notifiesOnChange;
public override bool IsRuntimeImmutable => this._type.IsEnum;
public override bool IsRuntimeImmutable => _type.IsEnum;
public override bool IsEnum => this._isFrameworkEnum;
public override bool IsEnum => _isFrameworkEnum;
}
}
+81 -81
View File
@@ -20,107 +20,107 @@ namespace Microsoft.Iris.Markup
private byte[] _currentBlock;
private ArrayList _blockList = new ArrayList();
public uint DataSize => this._totalSize;
public uint DataSize => _totalSize;
public void WriteByte(byte value)
{
this._scratch[0] = value;
this.Write(this._scratch, 1U);
_scratch[0] = value;
Write(_scratch, 1U);
}
public void WriteByte(OpCode value)
{
this._scratch[0] = (byte)value;
this.Write(this._scratch, 1U);
_scratch[0] = (byte)value;
Write(_scratch, 1U);
}
public void WriteBool(bool value)
{
this._scratch[0] = 0;
if (value) this._scratch[0] = 1;
this.Write(this._scratch, 1U);
_scratch[0] = 0;
if (value) _scratch[0] = 1;
Write(_scratch, 1U);
}
public void WriteChar(char value)
{
this._scratch[0] = (byte)value;
this._scratch[1] = (byte)((uint)value >> 8);
this.Write(this._scratch, 2U);
_scratch[0] = (byte)value;
_scratch[1] = (byte)((uint)value >> 8);
Write(_scratch, 2U);
}
public void WriteUInt16(ushort value)
{
this._scratch[0] = (byte)value;
this._scratch[1] = (byte)((uint)value >> 8);
this.Write(this._scratch, 2U);
_scratch[0] = (byte)value;
_scratch[1] = (byte)((uint)value >> 8);
Write(_scratch, 2U);
}
public void WriteUInt16(int rawValue)
{
ushort num = (ushort)rawValue;
this._scratch[0] = (byte)num;
this._scratch[1] = (byte)((uint)num >> 8);
this.Write(this._scratch, 2U);
_scratch[0] = (byte)num;
_scratch[1] = (byte)((uint)num >> 8);
Write(_scratch, 2U);
}
public void WriteUInt16(uint rawValue)
{
ushort num = (ushort)rawValue;
this._scratch[0] = (byte)num;
this._scratch[1] = (byte)((uint)num >> 8);
this.Write(this._scratch, 2U);
_scratch[0] = (byte)num;
_scratch[1] = (byte)((uint)num >> 8);
Write(_scratch, 2U);
}
public void WriteInt32(int value)
{
this._scratch[0] = (byte)value;
this._scratch[1] = (byte)(value >> 8);
this._scratch[2] = (byte)(value >> 16);
this._scratch[3] = (byte)(value >> 24);
this.Write(this._scratch, 4U);
_scratch[0] = (byte)value;
_scratch[1] = (byte)(value >> 8);
_scratch[2] = (byte)(value >> 16);
_scratch[3] = (byte)(value >> 24);
Write(_scratch, 4U);
}
public void WriteUInt32(uint value)
{
this._scratch[0] = (byte)value;
this._scratch[1] = (byte)(value >> 8);
this._scratch[2] = (byte)(value >> 16);
this._scratch[3] = (byte)(value >> 24);
this.Write(this._scratch, 4U);
_scratch[0] = (byte)value;
_scratch[1] = (byte)(value >> 8);
_scratch[2] = (byte)(value >> 16);
_scratch[3] = (byte)(value >> 24);
Write(_scratch, 4U);
}
public void WriteInt64(long value) => this.WriteUInt64((ulong)value);
public void WriteInt64(long value) => WriteUInt64((ulong)value);
public void WriteUInt64(ulong value)
{
this._scratch[0] = (byte)value;
this._scratch[1] = (byte)(value >> 8);
this._scratch[2] = (byte)(value >> 16);
this._scratch[3] = (byte)(value >> 24);
this._scratch[4] = (byte)(value >> 32);
this._scratch[5] = (byte)(value >> 40);
this._scratch[6] = (byte)(value >> 48);
this._scratch[7] = (byte)(value >> 56);
this.Write(this._scratch, 8U);
_scratch[0] = (byte)value;
_scratch[1] = (byte)(value >> 8);
_scratch[2] = (byte)(value >> 16);
_scratch[3] = (byte)(value >> 24);
_scratch[4] = (byte)(value >> 32);
_scratch[5] = (byte)(value >> 40);
_scratch[6] = (byte)(value >> 48);
_scratch[7] = (byte)(value >> 56);
Write(_scratch, 8U);
}
public unsafe void WriteSingle(float value)
{
uint num = *(uint*)&value;
this._scratch[0] = (byte)num;
this._scratch[1] = (byte)(num >> 8);
this._scratch[2] = (byte)(num >> 16);
this._scratch[3] = (byte)(num >> 24);
this.Write(this._scratch, 4U);
_scratch[0] = (byte)num;
_scratch[1] = (byte)(num >> 8);
_scratch[2] = (byte)(num >> 16);
_scratch[3] = (byte)(num >> 24);
Write(_scratch, 4U);
}
public unsafe void WriteDouble(double value) => this.WriteInt64(*(long*)&value);
public unsafe void WriteDouble(double value) => WriteInt64(*(long*)&value);
public void WriteString(string value)
{
if (value == null)
{
this.WriteUInt16(ushort.MaxValue);
WriteUInt16(ushort.MaxValue);
}
else
{
@@ -138,91 +138,91 @@ namespace Microsoft.Iris.Markup
uint length = (uint)value.Length;
if (!flag)
length |= 32768U;
this.WriteUInt16((ushort)length);
WriteUInt16((ushort)length);
foreach (char ch in value)
{
if (flag)
this.WriteChar(ch);
WriteChar(ch);
else
this.WriteByte((byte)ch);
WriteByte((byte)ch);
}
}
}
public void Write(ByteCodeReader value) => this.Write(value, 0U);
public void Write(ByteCodeReader value) => Write(value, 0U);
public unsafe void Write(ByteCodeReader value, uint offset)
{
IntPtr intPtr = value.ToIntPtr(out uint size);
if (offset > size)
throw new ArgumentOutOfRangeException(nameof(offset));
this.Write(new IntPtr(intPtr.ToInt64() + offset), (uint)(size - offset));
Write(new IntPtr(intPtr.ToInt64() + offset), (uint)(size - offset));
}
public unsafe void Write(byte[] buffer, uint count)
{
fixed (byte* pbData = buffer)
this.Write(pbData, count);
Write(pbData, count);
}
public unsafe void Write(IntPtr buffer, uint count) => this.Write((byte*)buffer.ToPointer(), count);
public unsafe void Write(IntPtr buffer, uint count) => Write((byte*)buffer.ToPointer(), count);
private unsafe void Write(byte* pbData, uint cbData)
{
while (cbData > 0U)
{
if (this._cbFreeInBlock == 0U)
if (_cbFreeInBlock == 0U)
{
this._currentBlock = new byte[4096];
this._blockList.Add(_currentBlock);
this._cbFreeInBlock = 4096U;
_currentBlock = new byte[4096];
_blockList.Add(_currentBlock);
_cbFreeInBlock = 4096U;
}
uint num1 = cbData <= this._cbFreeInBlock ? cbData : this._cbFreeInBlock;
uint num2 = 4096U - this._cbFreeInBlock;
Marshal.Copy(new IntPtr(pbData), this._currentBlock, (int)num2, (int)num1);
uint num1 = cbData <= _cbFreeInBlock ? cbData : _cbFreeInBlock;
uint num2 = 4096U - _cbFreeInBlock;
Marshal.Copy(new IntPtr(pbData), _currentBlock, (int)num2, (int)num1);
pbData += (int)num1;
cbData -= num1;
this._cbFreeInBlock -= num1;
this._totalSize += num1;
_cbFreeInBlock -= num1;
_totalSize += num1;
}
}
public void Overwrite(uint offset, uint value)
{
if (offset + 4U > this._totalSize)
if (offset + 4U > _totalSize)
throw new ArgumentException("Invalid offset");
this.OverwriteByte(offset, (byte)value);
this.OverwriteByte(offset + 1U, (byte)(value >> 8));
this.OverwriteByte(offset + 2U, (byte)(value >> 16));
this.OverwriteByte(offset + 3U, (byte)(value >> 24));
OverwriteByte(offset, (byte)value);
OverwriteByte(offset + 1U, (byte)(value >> 8));
OverwriteByte(offset + 2U, (byte)(value >> 16));
OverwriteByte(offset + 3U, (byte)(value >> 24));
}
private void OverwriteByte(uint offset, byte value) => ((byte[])this._blockList[(int)(offset / 4096U)])[(offset % 4096U)] = value;
private void OverwriteByte(uint offset, byte value) => ((byte[])_blockList[(int)(offset / 4096U)])[(offset % 4096U)] = value;
private unsafe byte* ComposeFinalBuffer(out uint totalSize)
{
byte* pointer = (byte*)NativeApi.MemAlloc(this._totalSize, false).ToPointer();
byte* pointer = (byte*)NativeApi.MemAlloc(_totalSize, false).ToPointer();
byte* numPtr = pointer;
for (int index = 0; index < this._blockList.Count - 1; ++index)
for (int index = 0; index < _blockList.Count - 1; ++index)
{
Marshal.Copy((byte[])this._blockList[index], 0, new IntPtr(numPtr), 4096);
Marshal.Copy((byte[])_blockList[index], 0, new IntPtr(numPtr), 4096);
numPtr += 4096;
}
uint num = 4096U - this._cbFreeInBlock;
if (this._currentBlock != null && num != 0U)
Marshal.Copy(this._currentBlock, 0, new IntPtr(numPtr), (int)num);
totalSize = this._totalSize;
this._blockList.Clear();
this._currentBlock = null;
this._cbFreeInBlock = 0U;
this._totalSize = 0U;
uint num = 4096U - _cbFreeInBlock;
if (_currentBlock != null && num != 0U)
Marshal.Copy(_currentBlock, 0, new IntPtr(numPtr), (int)num);
totalSize = _totalSize;
_blockList.Clear();
_currentBlock = null;
_cbFreeInBlock = 0U;
_totalSize = 0U;
return pointer;
}
public unsafe ByteCodeReader CreateReader()
{
uint totalSize;
return new ByteCodeReader(new IntPtr(this.ComposeFinalBuffer(out totalSize)), totalSize, true);
return new ByteCodeReader(new IntPtr(ComposeFinalBuffer(out totalSize)), totalSize, true);
}
}
}
@@ -20,6 +20,6 @@ namespace Microsoft.Iris.Markup
protected override IMarkupTypeBase GetMarkupTypeBase(object instance) => instance == null ? ((ClassTypeSchema)Owner).SharedInstance : (IMarkupTypeBase)instance;
public override bool IsStatic => ((ClassTypeSchema)this.Owner).IsShared;
public override bool IsStatic => ((ClassTypeSchema)Owner).IsShared;
}
}
@@ -15,18 +15,18 @@ namespace Microsoft.Iris.Markup
{
}
public override bool IsStatic => ((ClassTypeSchema)this.Owner).IsShared;
public override bool IsStatic => ((ClassTypeSchema)Owner).IsShared;
public override object GetValue(object instance)
{
ClassTypeSchema owner = (ClassTypeSchema)this.Owner;
return (instance == null ? owner.SharedInstance : (Class)instance).GetProperty(this.Name);
ClassTypeSchema owner = (ClassTypeSchema)Owner;
return (instance == null ? owner.SharedInstance : (Class)instance).GetProperty(Name);
}
public override void SetValue(ref object instance, object value)
{
ClassTypeSchema owner = (ClassTypeSchema)this.Owner;
(instance == null ? owner.SharedInstance : (Class)instance).SetProperty(this.Name, value);
ClassTypeSchema owner = (ClassTypeSchema)Owner;
(instance == null ? owner.SharedInstance : (Class)instance).SetProperty(Name, value);
}
}
}
+15 -15
View File
@@ -23,10 +23,10 @@ namespace Microsoft.Iris.Markup
protected override void OnDispose()
{
base.OnDispose();
if (this._sharedInstance == null)
if (_sharedInstance == null)
return;
this._sharedInstance.Dispose(this);
this._sharedInstance = null;
_sharedInstance.Dispose(this);
_sharedInstance = null;
}
public override MarkupType MarkupType => MarkupType.Class;
@@ -35,31 +35,31 @@ namespace Microsoft.Iris.Markup
public override Type RuntimeType => typeof(Class);
public override object ConstructDefault() => this._isShared ? SharedInstance : this.ConstructNewInstance();
public override object ConstructDefault() => _isShared ? SharedInstance : ConstructNewInstance();
public override void InitializeInstance(ref object instance) => this.InitializeInstance((IMarkupTypeBase)instance);
public override void InitializeInstance(ref object instance) => InitializeInstance((IMarkupTypeBase)instance);
public override bool HasInitializer => !this._isShared;
public override bool HasInitializer => !_isShared;
public override bool Disposable => !this._isShared && base.Disposable;
public override bool Disposable => !_isShared && base.Disposable;
public bool IsShared => this._isShared;
public bool IsShared => _isShared;
public void MarkShareable() => this._isShared = true;
public void MarkShareable() => _isShared = true;
public Class SharedInstance
{
get
{
if (!this._isShared)
if (!_isShared)
return null;
if (this._sharedInstance == null)
if (_sharedInstance == null)
{
this._sharedInstance = this.ConstructNewInstance();
this._sharedInstance.DeclareOwner(this);
this.InitializeInstance(_sharedInstance);
_sharedInstance = ConstructNewInstance();
_sharedInstance.DeclareOwner(this);
InitializeInstance(_sharedInstance);
}
return this._sharedInstance;
return _sharedInstance;
}
}
@@ -19,53 +19,53 @@ namespace Microsoft.Iris.Markup
public CompiledMarkupLoadResult(Resource resource, string uri)
: base(uri)
{
this._resource = resource;
_resource = resource;
if (uri != resource.Uri)
this._uriUnderlying = resource.Uri;
this._loader = CompiledMarkupLoader.Load(this, resource);
_uriUnderlying = resource.Uri;
_loader = CompiledMarkupLoader.Load(this, resource);
}
public override bool IsSource => false;
public override MarkupConstantsTable ConstantsTable => this._binaryDataTable.ConstantsTable;
public override MarkupConstantsTable ConstantsTable => _binaryDataTable.ConstantsTable;
public override MarkupImportTables ImportTables => this._binaryDataTable.ImportTables;
public override MarkupImportTables ImportTables => _binaryDataTable.ImportTables;
public void SetAddressOfLineNumberData(IntPtr address) => this._addressOfLineNumberData = address;
public void SetAddressOfLineNumberData(IntPtr address) => _addressOfLineNumberData = address;
public override MarkupLineNumberTable LineNumberTable
{
get
{
if (this._lineNumberTable == null)
this._lineNumberTable = CompiledMarkupLoader.DecodeLineNumberTable(this._addressOfLineNumberData);
return this._lineNumberTable;
if (_lineNumberTable == null)
_lineNumberTable = CompiledMarkupLoader.DecodeLineNumberTable(_addressOfLineNumberData);
return _lineNumberTable;
}
}
public override void Load(LoadPass currentPass)
{
if (this._loader == null)
if (_loader == null)
return;
ErrorManager.EnterContext(ErrorContextUri);
this._loader.Depersist(currentPass);
_loader.Depersist(currentPass);
ErrorManager.ExitContext();
if (currentPass != LoadPass.Done)
return;
this.LoadComplete();
LoadComplete();
}
private void LoadComplete()
{
if (this._resource != null)
if (_resource != null)
{
this._resource.Free();
this._resource = null;
_resource.Free();
_resource = null;
}
this._loader = null;
if (this.Status != LoadResultStatus.Loading)
_loader = null;
if (Status != LoadResultStatus.Loading)
return;
this.SetStatus(LoadResultStatus.Success);
SetStatus(LoadResultStatus.Success);
}
}
}
File diff suppressed because it is too large Load Diff
@@ -15,11 +15,11 @@ namespace Microsoft.Iris.Markup
public ConstructorSchema(TypeSchema owner)
{
this._owner = owner;
this.DeclareOwner(owner);
_owner = owner;
DeclareOwner(owner);
}
public TypeSchema Owner => this._owner;
public TypeSchema Owner => _owner;
public abstract TypeSchema[] ParameterTypes { get; }
@@ -15,21 +15,21 @@ namespace Microsoft.Iris.Markup
string watch,
DelegateListener.OnNotifyCallback callback)
{
this._watch = watch;
this._onNotify = callback;
_watch = watch;
_onNotify = callback;
notifier.AddListener(this);
}
public override void Dispose()
{
base.Dispose();
this._onNotify = null;
_onNotify = null;
}
public override void OnNotify()
{
base.OnNotify();
this._onNotify(this);
_onNotify(this);
}
public delegate void OnNotifyCallback(DelegateListener listener);
@@ -17,14 +17,14 @@ namespace Microsoft.Iris.Markup
uint scriptId,
uint refreshId)
{
this.Reset(notifier, watch, scriptHost, scriptId);
this._refreshId = refreshId;
Reset(notifier, watch, scriptHost, scriptId);
_refreshId = refreshId;
}
public override void OnNotify()
{
base.OnNotify();
this.ScriptHost.ScheduleScriptRun(this._refreshId, true);
ScriptHost.ScheduleScriptRun(_refreshId, true);
}
}
}
@@ -30,7 +30,7 @@ namespace Microsoft.Iris.Markup
protected override void SealWorker()
{
base.SealWorker();
this._defaultProperty = this.FindPropertyDeep("Default");
_defaultProperty = FindPropertyDeep("Default");
}
public override MarkupType MarkupType => MarkupType.Effect;
@@ -38,31 +38,31 @@ namespace Microsoft.Iris.Markup
protected override void OnDispose()
{
base.OnDispose();
if (this._effectTemplate == null)
if (_effectTemplate == null)
return;
this._effectTemplate.UnregisterUsage(this);
this._effectTemplate = null;
_effectTemplate.UnregisterUsage(this);
_effectTemplate = null;
}
protected override TypeSchema DefaultBase => EffectInstanceSchema.Type;
public override Type RuntimeType => typeof(EffectClass);
public string DefaultElementSymbol => this._defaultElementSymbolIndex >= 0 ? this.SymbolReferenceTable[this._defaultElementSymbolIndex].Symbol : null;
public string DefaultElementSymbol => _defaultElementSymbolIndex >= 0 ? SymbolReferenceTable[_defaultElementSymbolIndex].Symbol : null;
protected override Class ConstructNewInstance()
{
this.EnsureEffectTemplate();
return new EffectClass(this, this._effectTemplate);
EnsureEffectTemplate();
return new EffectClass(this, _effectTemplate);
}
protected override bool RunInitialEvaluates(IMarkupTypeBase scriptHost)
{
bool flag = true;
if (this._instancePropertyAssignments != null && this._templateIndexBuilt >= 0)
if (_instancePropertyAssignments != null && _templateIndexBuilt >= 0)
{
ErrorManager.EnterContext(this);
flag = this.RunInitializeScript(scriptHost, this._instancePropertyAssignments[this._templateIndexBuilt]);
flag = RunInitializeScript(scriptHost, _instancePropertyAssignments[_templateIndexBuilt]);
ErrorManager.ExitContext();
}
return flag && base.RunInitialEvaluates(scriptHost);
@@ -70,16 +70,16 @@ namespace Microsoft.Iris.Markup
private void EnsureEffectTemplate()
{
if (this._effectTemplate != null)
if (_effectTemplate != null)
return;
this._effectTemplate = UISession.Default.RenderSession.CreateEffectTemplate(this, this.Name);
_effectTemplate = UISession.Default.RenderSession.CreateEffectTemplate(this, Name);
ErrorManager.EnterContext(this);
Class @class = new Class(this);
@class.DeclareOwner(this);
this._templateIndexBuilt = -1;
for (int index = 0; index < this._techniqueOffsets.Length; ++index)
_templateIndexBuilt = -1;
for (int index = 0; index < _techniqueOffsets.Length; ++index)
{
object obj = this.RunAtOffset(@class, this._techniqueOffsets[index]);
object obj = RunAtOffset(@class, _techniqueOffsets[index]);
if (obj == Interpreter.ScriptError)
{
if (!ErrorManager.IgnoringErrors)
@@ -88,14 +88,14 @@ namespace Microsoft.Iris.Markup
else
{
EffectInput input = (EffectInput)obj;
if (this._dynamicElementAssignments != null)
if (_dynamicElementAssignments != null)
{
foreach (string elementAssignment in this._dynamicElementAssignments)
this._effectTemplate.AddEffectProperty(elementAssignment);
foreach (string elementAssignment in _dynamicElementAssignments)
_effectTemplate.AddEffectProperty(elementAssignment);
}
if (this._effectTemplate.Build(input))
if (_effectTemplate.Build(input))
{
this._templateIndexBuilt = index;
_templateIndexBuilt = index;
break;
}
}
@@ -104,20 +104,20 @@ namespace Microsoft.Iris.Markup
ErrorManager.ExitContext();
}
public uint[] TechniqueOffsets => this._techniqueOffsets;
public uint[] TechniqueOffsets => _techniqueOffsets;
public uint[] InstancePropertyAssignments => this._instancePropertyAssignments;
public uint[] InstancePropertyAssignments => _instancePropertyAssignments;
public string[] DynamicElementAssignments => this._dynamicElementAssignments;
public string[] DynamicElementAssignments => _dynamicElementAssignments;
public int DefaultElementSymbolIndex => this._defaultElementSymbolIndex;
public int DefaultElementSymbolIndex => _defaultElementSymbolIndex;
public void SetTechniqueOffsets(uint[] techniqueOffsets) => this._techniqueOffsets = techniqueOffsets;
public void SetTechniqueOffsets(uint[] techniqueOffsets) => _techniqueOffsets = techniqueOffsets;
public void SetInstancePropertyAssignments(uint[] instancePropertyAssignments) => this._instancePropertyAssignments = instancePropertyAssignments;
public void SetInstancePropertyAssignments(uint[] instancePropertyAssignments) => _instancePropertyAssignments = instancePropertyAssignments;
public void SetDynamicElementAssignments(string[] dynamicElementAssignments) => this._dynamicElementAssignments = dynamicElementAssignments;
public void SetDynamicElementAssignments(string[] dynamicElementAssignments) => _dynamicElementAssignments = dynamicElementAssignments;
public void SetDefaultElementSymbolIndex(int symbolIndex) => this._defaultElementSymbolIndex = symbolIndex;
public void SetDefaultElementSymbolIndex(int symbolIndex) => _defaultElementSymbolIndex = symbolIndex;
}
}

Some files were not shown because too many files have changed in this diff Show More