internal Getters[] GetGetters(Type type, bool ShowReadOnlyProperties, List<Type> IgnoreAttributes)
{
Getters[] val = null;
if (_getterscache.TryGetValue(type, out val))
return val;
PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
List<Getters> getters = new List<Getters>();
foreach (PropertyInfo p in props)
{
if (p.GetIndexParameters().Length > 0)
{// Property is an indexer
continue;
}
if (!p.CanWrite && ShowReadOnlyProperties == false) continue;
if (IgnoreAttributes != null)
{
bool found = false;
foreach (var ignoreAttr in IgnoreAttributes)
{
if (p.IsDefined(ignoreAttr, false))
{
found = true;
break;
}
}
if (found)
continue;
}
GenericGetter g = CreateGetMethod(type, p);
if (g != null)
getters.Add(new Getters { Getter = g, Name = p.Name, lcName = p.Name.ToLower() });
}
FieldInfo[] fi = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static);
foreach (var f in fi)
{
if (IgnoreAttributes != null)
{
bool found = false;
foreach (var ignoreAttr in IgnoreAttributes)
{
if (f.IsDefined(ignoreAttr, false))
{
found = true;
break;
}
}
if (found)
continue;
}
if (f.IsLiteral == false)
{
GenericGetter g = CreateGetField(type, f);
if (g != null)
getters.Add(new Getters { Getter = g, Name = f.Name, lcName = f.Name.ToLower() });
}
}
val = getters.ToArray();
_getterscache.Add(type, val);
return val;
}