public void RegisterCustomType(Type type, Serialize serializer, Deserialize deserializer) { if (type != null && serializer != null && deserializer != null) { _customSerializer.Add(type, serializer); _customDeserializer.Add(type, deserializer); // reset property cache _propertycache = new SafeDictionary <string, SafeDictionary <string, myPropInfo> >(); } }
private SafeDictionary <string, myPropInfo> Getproperties(Type type, string typename) { SafeDictionary <string, myPropInfo> sd = null; if (_propertycache.TryGetValue(typename, out sd)) { return(sd); } sd = new SafeDictionary <string, myPropInfo>(); var pr = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); foreach (var p in pr) { myPropInfo d = CreateMyProp(p.PropertyType, p.Name); d.CanWrite = p.CanWrite; d.setter = CreateSetMethod(p); d.getter = CreateGetMethod(p); sd.Add(p.Name, d); } _propertycache.Add(typename, sd); return(sd); }