Exemple #1
0
        private static void GetChildPrivateProperties(IList <PropertyInfo> initialProperties, Type targetType, BindingFlags bindingAttr)
        {
            if ((bindingAttr & BindingFlags.NonPublic) == BindingFlags.Default)
            {
                return;
            }
            BindingFlags bindingAttr1 = ReflectionUtils.RemoveFlag(bindingAttr, BindingFlags.Public);

            while ((targetType = TypeExtensions.BaseType(targetType)) != null)
            {
                foreach (PropertyInfo propertyInfo in targetType.GetProperties(bindingAttr1))
                {
                    PropertyInfo nonPublicProperty = propertyInfo;
                    int          index             = CollectionUtils.IndexOf <PropertyInfo>((IEnumerable <PropertyInfo>)initialProperties, (Func <PropertyInfo, bool>)(p => p.Name == nonPublicProperty.Name));
                    if (index == -1)
                    {
                        initialProperties.Add(nonPublicProperty);
                    }
                    else
                    {
                        initialProperties[index] = nonPublicProperty;
                    }
                }
            }
        }
Exemple #2
0
        private static void GetChildPrivateFields(IList <MemberInfo> initialFields, Type targetType, BindingFlags bindingAttr)
        {
            if ((bindingAttr & BindingFlags.NonPublic) == BindingFlags.Default)
            {
                return;
            }
            BindingFlags bindingAttr1 = ReflectionUtils.RemoveFlag(bindingAttr, BindingFlags.Public);

            while ((targetType = TypeExtensions.BaseType(targetType)) != null)
            {
                IEnumerable <MemberInfo> collection = Enumerable.Cast <MemberInfo>((IEnumerable)Enumerable.Where <FieldInfo>((IEnumerable <FieldInfo>)targetType.GetFields(bindingAttr1), (Func <FieldInfo, bool>)(f => f.IsPrivate)));
                CollectionUtils.AddRange <MemberInfo>(initialFields, collection);
            }
        }