public Dictionary<string, myPropInfo> Getproperties(Type type, string typename, 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 | BindingFlags.Static);
foreach (PropertyInfo p in pr)
{
if (p.GetIndexParameters().Length > 0)
{// Property is an indexer
continue;
}
myPropInfo d = CreateMyProp(p.PropertyType, p.Name, customType);
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(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
foreach (FieldInfo f in fi)
{
myPropInfo d = CreateMyProp(f.FieldType, f.Name, customType);
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;
}
}