コード例 #1
0
ファイル: Reflection.cs プロジェクト: sirctseb/Scope
 public static IEnumerable<System.Reflection.PropertyInfo> GetAllProps(Object obj)
 {
     System.Reflection.BindingFlags propFlags =
         //System.Reflection.BindingFlags.FlattenHierarchy |
         System.Reflection.BindingFlags.DeclaredOnly |
         System.Reflection.BindingFlags.GetProperty |
         System.Reflection.BindingFlags.Instance |
         System.Reflection.BindingFlags.Static |
         System.Reflection.BindingFlags.Public |
         System.Reflection.BindingFlags.NonPublic;
     System.Reflection.PropertyInfo[] props = new System.Reflection.PropertyInfo[] { };
     Type objType = obj.GetType();
     while (objType != null)
     {
         props = props.Concat(objType.GetProperties(propFlags)).ToArray();
         objType = objType.BaseType;
     }
     return props;
 }