public NestedTypes( ITypeWithReflection declaringType, INestedTypeFactory <TNestedAbstractClass, TNestedClass, TNestedSealedClass, TNestedStaticClass, TNestedDelegate, TNestedEnum, TNestedInterface, TNestedStruct> factory) { List <TNestedAbstractClass> nestedAbstractClasses = new List <TNestedAbstractClass>(); List <TNestedClass> nestedClasses = new List <TNestedClass>(); List <TNestedSealedClass> nestedSealedClasses = new List <TNestedSealedClass>(); List <TNestedStaticClass> nestedStaticClasses = new List <TNestedStaticClass>(); List <TNestedDelegate> nestedDelegates = new List <TNestedDelegate>(); List <TNestedEnum> nestedEnums = new List <TNestedEnum>(); List <TNestedInterface> nestedInterfaces = new List <TNestedInterface>(); List <TNestedStruct> nestedStructs = new List <TNestedStruct>(); foreach (Type nestedType in declaringType.Type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)) { switch (nestedType.TypeClassification()) { case TypeClassification.AbstractClass: nestedAbstractClasses.Add(factory.CreateNestedAbstractClass(declaringType, nestedType)); break; case TypeClassification.Class: nestedClasses.Add(factory.CreateNestedClass(declaringType, nestedType)); break; case TypeClassification.SealedClass: nestedSealedClasses.Add(factory.CreateNestedSealedClass(declaringType, nestedType)); break; case TypeClassification.StaticClass: nestedStaticClasses.Add(factory.CreateNestedStaticClass(declaringType, nestedType)); break; case TypeClassification.Delegate: nestedDelegates.Add(factory.CreateNestedDelegate(declaringType, nestedType)); break; case TypeClassification.Enum: nestedEnums.Add(factory.CreateNestedEnum(declaringType, nestedType)); break; case TypeClassification.Interface: nestedInterfaces.Add(factory.CreateNestedInterface(declaringType, nestedType)); break; case TypeClassification.Struct: nestedStructs.Add(factory.CreateNestedStruct(declaringType, nestedType)); break; } } NestedAbstractClasses = nestedAbstractClasses; NestedClasses = nestedClasses; NestedSealedClasses = nestedSealedClasses; NestedStaticClasses = nestedStaticClasses; NestedDelegates = nestedDelegates; NestedEnums = nestedEnums; NestedInterfaces = nestedInterfaces; NestedStructs = nestedStructs; }
public Constructors( ITypeWithReflection declaringType, Type type, Func <ITypeWithReflection, ConstructorInfo, TConstructor> constructorFactory) { List <TConstructor> constructors = new List <TConstructor>(); foreach (ConstructorInfo constructor in type.GetAllConstructors()) { if (constructor.IsStatic) { StaticConstructorWithReflection = new StaticConstructorWithReflection(declaringType, constructor); } else { constructors.Add(constructorFactory(declaringType, constructor)); } } ConstructorsWithReflection = constructors; }
protected abstract TNestedStruct CreateNestedStruct(ITypeWithReflection declaringType, Type type);
protected abstract TNestedInterface CreateNestedInterface(ITypeWithReflection declaringType, Type type);
protected abstract TNestedEnum CreateNestedEnum(ITypeWithReflection declaringType, Type type);
protected abstract TNestedDelegate CreateNestedDelegate(ITypeWithReflection declaringType, Type type);
protected abstract TNestedClass CreateNestedClass(ITypeWithReflection declaringType, Type type);
protected abstract TConstructor CreateConstructor(ITypeWithReflection declaringType, ConstructorInfo constructor);
TNestedStruct INestedTypeFactory <TNestedAbstractClass, TNestedClass, TNestedSealedClass, TNestedStaticClass, TNestedDelegate, TNestedEnum, TNestedInterface, TNestedStruct> .CreateNestedStruct( ITypeWithReflection declaringType, Type type) { return(CreateNestedStruct(declaringType, type)); }
protected override ClassNestedStructWithReflection CreateNestedStruct(ITypeWithReflection declaringType, Type type) { return(new ClassNestedStructWithReflection(declaringType, type)); }
protected override ClassNestedSealedClassWithReflection CreateNestedSealedClass(ITypeWithReflection declaringType, Type type) { return(new ClassNestedSealedClassWithReflection((IInternalTypeWithReflection)declaringType, type)); }
protected override ClassNestedAbstractClassWithReflection CreateNestedAbstractClass(ITypeWithReflection declaringType, Type type) { return(new ClassNestedAbstractClassWithReflection(declaringType, type)); }
protected override ClassConstructorWithReflection CreateConstructor(ITypeWithReflection declaringType, ConstructorInfo constructor) { return(new ClassConstructorWithReflection(declaringType, constructor)); }