VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
object AVR.Core.AVR_Logger.getPropertyValue ( object  target,
string  field 
)
inlineprivate

Definition at line 120 of file AVR_Logger.cs.

120  {
121  if (target == null || field==null) return null;
122 
123  if (field.Contains("."))//complex type nested
124  {
125  var temp = field.Split(new char[] { '.' }, 2);
126  return getPropertyValue(getPropertyValue(target, temp[0]), temp[1]);
127  }
128  else
129  {
130  // Return field or proprty depending on which one it is
131  // NOTE: use "GetProperty(field, System.Reflection.BindingFlags.NonPublic)" for non-public fields.
132  BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Default | BindingFlags.GetField | BindingFlags.GetProperty;
133  try {
134  return target.GetType().GetProperty(field, flags).GetValue(target, null);
135  }
136  catch(System.Exception) {
137  return target.GetType().GetField(field, flags).GetValue(target);
138  }
139  }
140  }
object getPropertyValue(object target, string field)
Definition: AVR_Logger.cs:120