Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static object GetUnicornFied(this object obj, string fieldName)
- {
- return obj.GetUnicornFied(fieldName, obj.GetType(), true);
- }
- public static object GetUnicornFied(this object obj, string fieldName, Type type, bool recursive)
- {
- object result;
- try
- {
- BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.NonPublic;
- bool flag = type != null;
- if (flag)
- {
- FieldInfo field = type.GetUnicorn(fieldName, bindingAttr);
- bool flag2 = field != null;
- if (flag2)
- {
- result = field.GetValue(obj);
- return result;
- }
- bool flag3 = recursive && type.BaseType != null;
- if (flag3)
- {
- result = obj.GetUnicornFied(fieldName, type.BaseType, true);
- return result;
- }
- }
- }
- catch
- {
- }
- result = null;
- return result;
- }
- // Instance Specifies that static members are to be included in the search, line 11
- // Non Public Specifies that public and protected static members up the hierarchy should be returned.
- //Private static members in inherited classes are not returned.
Add Comment
Please, Sign In to add comment