Пример #1
0
        internal static IEnumerable <PropertyInfo> GetAllProperties(Type type, BindingFlags flags)
        {
            var seen = new Dictionary <MetaPosition, PropertyInfo>();

            Type currentType = type;

            do
            {
                foreach (PropertyInfo pi in currentType.GetProperties(flags))
                {
                    if (type == currentType || IsPrivate(pi))
                    {
                        var mp = new MetaPosition(pi);
                        seen[mp] = pi;
                    }
                }

                currentType = currentType.BaseType;
            } while (currentType != null);

            return(seen.Values);
        }
Пример #2
0
        internal static IEnumerable <FieldInfo> GetAllFields(Type type, BindingFlags flags)
        {
            var seen = new Dictionary <MetaPosition, FieldInfo>();

            Type currentType = type;

            do
            {
                foreach (FieldInfo fi in currentType.GetFields(flags))
                {
                    if (fi.IsPrivate || type == currentType)
                    {
                        var mp = new MetaPosition(fi);
                        seen[mp] = fi;
                    }
                }

                currentType = currentType.BaseType;
            } while (currentType != null);

            return(seen.Values);
        }