Example #1
0
        /// <summary> get fields including which in base classes. </summary>
        public IReadOnlyList<FieldInfo> GetAllFields(object obj, VisitPolicy policy)
        {
            ArrayBuilder<FieldInfo> fieldInfos = new ArrayBuilder<FieldInfo>();

            Type t = obj.GetType();
            do {
                fieldInfos.Concat(t.GetFields((BindingFlags)policy));
                t = t.BaseType;
            } while (t != typeof(object));

            return fieldInfos.ToReadOnlyList();
        }