Hello
I have a function that accepts any object, then it gets values from the properties or fields that it has as input.
It currently looks like this:
private string GetFieldValue(object o, Field f)
{
//field.name is name of property or field
MemberInfo[] mi = o.GetType().GetMember(field.name, MemberTypes.Field | MemberTypes.Property,
BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.ExactBinding );
if (mi.Length == 0) throw new ArgumentException("Field", "Can't find member: " + f.name);
Object value;
if (mi[0].MemberType == MemberTypes.Property)
value = ((PropertyInfo)mi[0]).GetValue(o, null);
else value = ((FieldInfo)mi[0]).GetValue(o);
Today I read about System.ComponentModel and its XXXDescriptor classes. What is the difference, when performance is in question, between 2 frameworks (Reflection & ComponentModel). Will rewriting the above using ComponentModel achieve better performance or flexibility ? The only other difference between those two that I know is support for virtual properties by CM.
Ty.