public void Unregister(IProxyMemberInfo memberInfo) { if (!memberInfo.DeclaringType.Equals(type)) { throw new ArgumentException(); } string name = memberInfo.Name; if (memberInfo is IProxyPropertyInfo) { this.properties.Remove(name); } else if (memberInfo is IProxyMethodInfo) { this.RemoveMethodInfo((IProxyMethodInfo)memberInfo); } else if (memberInfo is IProxyFieldInfo) { this.fields.Remove(name); } else if (memberInfo is IProxyEventInfo) { this.events.Remove(name); } else if (memberInfo is IProxyItemInfo) { if (this.itemInfo == memberInfo) { this.itemInfo = null; } } }
protected IProxyItemInfo CreateProxyItemInfo(PropertyInfo propertyInfo) { Type type = propertyInfo.DeclaringType; ParameterInfo[] parameters = propertyInfo.GetIndexParameters(); if (parameters == null || parameters.Length != 1) { throw new NotSupportedException(); } IProxyItemInfo info = null; #if UNITY_IOS if (type.IsSubclassOfGenericTypeDefinition(typeof(IDictionary <,>))) { info = this.CreateDictionaryProxyItemInfo(propertyInfo); } else if (type.IsSubclassOfGenericTypeDefinition(typeof(IList <>))) { info = this.CreateListProxyItemInfo(propertyInfo); } else { info = new ProxyItemInfo(propertyInfo); } #else try { if (type.IsSubclassOfGenericTypeDefinition(typeof(IDictionary <,>))) { info = (IProxyItemInfo)Activator.CreateInstance(typeof(DictionaryProxyItemInfo <, ,>).MakeGenericType(type, parameters[0].ParameterType, propertyInfo.PropertyType), propertyInfo); } else if (type.IsSubclassOfGenericTypeDefinition(typeof(IList <>))) { info = (IProxyItemInfo)Activator.CreateInstance(typeof(ListProxyItemInfo <,>).MakeGenericType(type, propertyInfo.PropertyType), propertyInfo); } else { info = new ProxyItemInfo(propertyInfo); } } catch (Exception) { info = new ProxyItemInfo(propertyInfo); } #endif if (info != null) { this.itemInfo = info; } return(info); }
public ItemNodeProxy(ICollection source, T key, IProxyItemInfo itemInfo) : base(source) { this.key = key; this.isList = (source is IList); this.itemInfo = itemInfo; if (this.source != null && this.source is INotifyCollectionChanged) { var sourceCollection = this.source as INotifyCollectionChanged; sourceCollection.CollectionChanged += OnCollectionChanged; } if (!this.isList) { this.regex = new Regex(@"\[" + this.key + ",", RegexOptions.IgnorePatternWhitespace); } }
public StringItemNodeProxy(ICollection source, string key, IProxyItemInfo itemInfo) : base(source, key, itemInfo) { }
public IntItemNodeProxy(ICollection source, int key, IProxyItemInfo itemInfo) : base(source, key, itemInfo) { }
protected IProxyItemInfo CreateArrayProxyItemInfo(Type type) { var elementType = type.GetElementType(); IProxyItemInfo info = null; #if UNITY_IOS var code = Type.GetTypeCode(elementType); switch (code) { case TypeCode.Boolean: info = new ArrayProxyItemInfo <bool[], bool>(); break; case TypeCode.Byte: info = new ArrayProxyItemInfo <byte[], byte>(); break; case TypeCode.Char: info = new ArrayProxyItemInfo <char[], char>(); break; case TypeCode.DateTime: info = new ArrayProxyItemInfo <DateTime[], DateTime>(); break; case TypeCode.Decimal: info = new ArrayProxyItemInfo <Decimal[], Decimal>(); break; case TypeCode.Double: info = new ArrayProxyItemInfo <Double[], Double>(); break; case TypeCode.Int16: info = new ArrayProxyItemInfo <Int16[], Int16>(); break; case TypeCode.Int32: info = new ArrayProxyItemInfo <Int32[], Int32>(); break; case TypeCode.Int64: info = new ArrayProxyItemInfo <Int64[], Int64>(); break; case TypeCode.SByte: info = new ArrayProxyItemInfo <SByte[], SByte>(); break; case TypeCode.Single: info = new ArrayProxyItemInfo <Single[], Single>(); break; case TypeCode.String: info = new ArrayProxyItemInfo <string[], string>(); break; case TypeCode.UInt16: info = new ArrayProxyItemInfo <UInt16[], UInt16>(); break; case TypeCode.UInt32: info = new ArrayProxyItemInfo <UInt32[], UInt32>(); break; case TypeCode.UInt64: info = new ArrayProxyItemInfo <UInt64[], UInt64>(); break; case TypeCode.Object: { if (type.Equals(typeof(Vector2))) { info = new ArrayProxyItemInfo <Vector2[], Vector2>(); } else if (type.Equals(typeof(Vector3))) { info = new ArrayProxyItemInfo <Vector3[], Vector3>(); } else if (type.Equals(typeof(Vector4))) { info = new ArrayProxyItemInfo <Vector4[], Vector4>(); } else if (type.Equals(typeof(Color))) { info = new ArrayProxyItemInfo <Color[], Color>(); } else if (type.Equals(typeof(Rect))) { info = new ArrayProxyItemInfo <Rect[], Rect>(); } else if (type.Equals(typeof(Quaternion))) { info = new ArrayProxyItemInfo <Quaternion[], Quaternion>(); } else if (type.Equals(typeof(Version))) { info = new ArrayProxyItemInfo <Version[], Version>(); } else { info = new ArrayProxyItemInfo(type); } break; } default: info = new ArrayProxyItemInfo(type); break; } #else info = (IProxyItemInfo)Activator.CreateInstance(typeof(ArrayProxyItemInfo <,>).MakeGenericType(type, elementType)); #endif if (info != null) { this.itemInfo = info; } return(info); }