I have a function that takes any object, then it gets the values ββfrom the properties or fields that it has as input.
Now it 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 it comes to performance, between two frames (Reflection and ComponentModel). Does this overwrite using ComponentModel provide better performance or flexibility? The only difference between the two that I know is support for virtual properties using CM.
Ty.
source share