/// <summary>
/// Reads all fields with the specified binding of the object in alphabetical order using reflection
/// </summary>
public void ReadAllFields(object target, BindingFlags flags)
{
if (target == null)
{
return;
}
Type tp = target.GetType();
FieldInfo[] fields = tp.GetFields(flags);
NetUtility.SortMembersList(fields);
foreach (FieldInfo fi in fields)
{
object value;
// find read method
MethodInfo readMethod;
if (s_readMethods.TryGetValue(fi.FieldType, out readMethod))
{
// read value
value = readMethod.Invoke(this, null);
// set the value
fi.SetValue(target, value);
}
}
}