internal void ClearReflectionCache() { _tyname = new SafeDictionary <Type, string>(); _typecache = new SafeDictionary <string, Type>(); _constrcache = new SafeDictionary <Type, CreateObject>(); _getterscache = new SafeDictionary <Type, Getters[]>(); _propertycache = new SafeDictionary <string, Dictionary <string, myPropInfo> >(); _genericTypes = new SafeDictionary <Type, Type[]>(); _genericTypeDef = new SafeDictionary <Type, Type>(); }
internal void ResetPropertyCache() { _propertycache = new SafeDictionary <string, Dictionary <string, myPropInfo> >(); }
private object ParseDictionary(Dictionary <string, object> d, Dictionary <string, object> globaltypes, Type type, object input) { object tn = ""; if (d.TryGetValue("$types", out tn)) { _globalTypes = true; if (globaltypes == null) { globaltypes = new Dictionary <string, object>(); } foreach (var kv in (Dictionary <string, object>)tn) { globaltypes.Add((string)kv.Key, kv.Value); } } bool found = d.TryGetValue("$type", out tn); #if !SILVERLIGHT if (found == false && type == typeof(System.Object)) { return(CreateDataset(d, globaltypes)); } #endif if (found) { if (_globalTypes && globaltypes != null) { object tname = ""; if (globaltypes.TryGetValue((string)tn, out tname)) { tn = tname; } } type = Reflection.Instance.GetTypeFromCache((string)tn); } if (type == null) { throw new Exception("Cannot determine type"); } string typename = type.FullName; object o = input; if (o == null) { o = Reflection.Instance.FastCreateInstance(type); } SafeDictionary <string, myPropInfo> props = Getproperties(type, typename); foreach (string name in d.Keys) { myPropInfo pi; if (props.TryGetValue(name, out pi) == false) { continue; } if ((pi.Flags & (myPropInfoFlags.Filled | myPropInfoFlags.CanWrite)) != 0) { object v = d[name]; if (v != null) { object oset = v; switch (pi.Type) { #if !SILVERLIGHT case myPropInfoType.DataSet: oset = CreateDataset((Dictionary <string, object>)v, globaltypes); break; case myPropInfoType.DataTable: oset = CreateDataTable((Dictionary <string, object>)v, globaltypes); break; #endif case myPropInfoType.Custom: oset = CreateCustom((string)v, pi.pt); break; case myPropInfoType.Enum: oset = CreateEnum(pi.pt, (string)v); break; case myPropInfoType.StringDictionary: oset = CreateStringKeyDictionary((Dictionary <string, object>)v, pi.pt, pi.GenericTypes, globaltypes); break; case myPropInfoType.Hashtable: case myPropInfoType.Dictionary: oset = CreateDictionary((List <object>)v, pi.pt, pi.GenericTypes, globaltypes); break; case myPropInfoType.Array: oset = CreateArray((List <object>)v, pi.pt, pi.bt, globaltypes); break; default: { if (pi.IsGenericType && pi.IsValueType == false) { oset = CreateGenericList((List <object>)v, pi.pt, pi.bt, globaltypes); } else if (pi.IsClass && v is Dictionary <string, object> ) { oset = ParseDictionary((Dictionary <string, object>)v, globaltypes, pi.pt, input); } else if (v is List <object> ) { oset = CreateArray((List <object>)v, pi.pt, typeof(object), globaltypes); } break; } } o = pi.setter(o, oset); } } } return(o); }