Esempio n. 1
0
        public static PropInfo FindProp(object obj, System.Reflection.MemberInfo member)
        {
            PropInfo result;

            if (member is System.Reflection.PropertyInfo)
            {
                result = new PropInfo(obj, (System.Reflection.PropertyInfo)member);
            }
            else if (member is System.Reflection.FieldInfo)
            {
                result = new PropInfo(obj, (System.Reflection.FieldInfo)member);
            }
            else
            {
                result = null;
            }
            return(result);
        }
Esempio n. 2
0
 public static PropInfo[] GetProps(object obj)
 {
     System.Reflection.BindingFlags bindingAttr = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public;
     System.Type type = obj.GetType();
     System.Collections.Generic.List <PropInfo> list       = new System.Collections.Generic.List <PropInfo>();
     System.Reflection.PropertyInfo[]           properties = type.GetProperties(bindingAttr);
     for (int i = 0; i < properties.Length; i++)
     {
         System.Reflection.PropertyInfo prop = properties[i];
         list.Add(new PropInfo(obj, prop));
     }
     System.Reflection.FieldInfo[] fields = type.GetFields(bindingAttr);
     for (int i = 0; i < fields.Length; i++)
     {
         System.Reflection.FieldInfo field = fields[i];
         list.Add(new PropInfo(obj, field));
     }
     PropInfo[] array = new PropInfo[list.Count];
     list.CopyTo(array);
     return(array);
 }
Esempio n. 3
0
        public static void SetPropValue(object obj, string name, object value)
        {
            PropInfo prop = ReflectionUtils.GetProp(obj, name);

            prop.Value = value;
        }
Esempio n. 4
0
        public static object GetPropValue(object obj, string name)
        {
            PropInfo prop = ReflectionUtils.GetProp(obj, name);

            return(prop.Value);
        }