Exemplo n.º 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;
                    }
                }
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
 private static bool InheritsGenericDefinitionInternal(Type currentType, Type genericClassDefinition, out Type implementingType)
 {
     if (TypeExtensions.IsGenericType(currentType))
     {
         Type genericTypeDefinition = currentType.GetGenericTypeDefinition();
         if (genericClassDefinition == genericTypeDefinition)
         {
             implementingType = currentType;
             return(true);
         }
     }
     if (TypeExtensions.BaseType(currentType) != null)
     {
         return(ReflectionUtils.InheritsGenericDefinitionInternal(TypeExtensions.BaseType(currentType), genericClassDefinition, out implementingType));
     }
     implementingType = (Type)null;
     return(false);
 }
Exemplo n.º 4
0
 public static bool AssignableToTypeName(this Type type, string fullTypeName, out Type match)
 {
     for (Type type1 = type; type1 != null; type1 = TypeExtensions.BaseType(type1))
     {
         if (string.Equals(type1.FullName, fullTypeName, StringComparison.Ordinal))
         {
             match = type1;
             return(true);
         }
     }
     foreach (MemberInfo memberInfo in type.GetInterfaces())
     {
         if (string.Equals(memberInfo.Name, fullTypeName, StringComparison.Ordinal))
         {
             match = type;
             return(true);
         }
     }
     match = (Type)null;
     return(false);
 }