public Dictionary <string, myPropInfo> Getproperties(Type type, string typename, bool IgnoreCaseOnDeserialize, bool customType) { Dictionary <string, myPropInfo> sd = null; if (_propertycache.TryGetValue(typename, out sd)) { return(sd); } else { sd = new Dictionary <string, myPropInfo>(); PropertyInfo[] pr = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo p in pr) { myPropInfo d = CreateMyProp(p.PropertyType, p.Name, customType); //if (p.CanWrite) // d.Flags |= myPropInfoFlags.CanWrite; d.setter = Reflection.CreateSetMethod(type, p); if (d.setter != null) { d.CanWrite = true;// Flags |= myPropInfoFlags.CanWrite; } d.getter = Reflection.CreateGetMethod(type, p); if (IgnoreCaseOnDeserialize) { sd.Add(p.Name.ToLower(), d); } else { sd.Add(p.Name, d); } } FieldInfo[] fi = type.GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo f in fi) { myPropInfo d = CreateMyProp(f.FieldType, f.Name, customType); d.CanWrite = true;// Flags |= myPropInfoFlags.CanWrite; d.setter = Reflection.CreateSetField(type, f); d.getter = Reflection.CreateGetField(type, f); if (IgnoreCaseOnDeserialize) { sd.Add(f.Name.ToLower(), d); } else { sd.Add(f.Name, d); } } _propertycache.Add(typename, sd); return(sd); } }
public Dictionary <string, myPropInfo> Getproperties(Type type, string typename) { Dictionary <string, myPropInfo> sd = null; if (_propertycache.TryGetValue(typename, out sd)) { return(sd); } else { sd = new Dictionary <string, myPropInfo>(); var bf = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static; PropertyInfo[] pr = type.GetProperties(bf); foreach (PropertyInfo p in pr) { if (p.GetIndexParameters().Length > 0)// Property is an indexer { continue; } myPropInfo d = CreateMyProp(p.PropertyType, p.Name); d.setter = Reflection.CreateSetMethod(type, p); if (d.setter != null) { d.CanWrite = true; } d.getter = Reflection.CreateGetMethod(type, p); sd.Add(p.Name.ToLower(), d); } FieldInfo[] fi = type.GetFields(bf); foreach (FieldInfo f in fi) { myPropInfo d = CreateMyProp(f.FieldType, f.Name); if (f.IsLiteral == false) { d.setter = Reflection.CreateSetField(type, f); if (d.setter != null) { d.CanWrite = true; } d.getter = Reflection.CreateGetField(type, f); sd.Add(f.Name.ToLower(), d); } } _propertycache.Add(typename, sd); return(sd); } }