Beispiel #1
0
        public TypeMetadata(Type type)
        {
            TypeEnum = TypeEnumFactory.CreateTypeMetadataClass(type);

            FullTypeName     = type.FullName;
            TypeName         = type.Name;
            NamespaceName    = type.Namespace;
            GenericArguments = !type.IsGenericTypeDefinition && !type.IsConstructedGenericType ? null : EmitGenericArguments(type.GetGenericArguments());
            Modifiers        = EmitModifiers(type);
            Attributes       = AttributeMetadata.EmitAttributes(type);

            DeclaringType = EmitDeclaringType(type.DeclaringType);

            BaseType = EmitExtends(type.BaseType);
            ImplementedInterfaces = EmitImplements(type.GetInterfaces());

            BindingFlags flagsToGetAll = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;

            Fields       = FieldMetadata.EmitFields(type.GetFields(flagsToGetAll));
            Methods      = MethodMetadata.EmitMethods(type.GetMethods(flagsToGetAll));
            Properties   = PropertyMetadata.EmitProperties(type.GetProperties(flagsToGetAll));
            Indexers     = IndexerMetadata.EmitIndexers(type.GetProperties(flagsToGetAll));
            Events       = EventMetadata.EmitEvents(type.GetEvents(flagsToGetAll));
            Constructors = ConstructorMetadata.EmitConstructors(type.GetConstructors(flagsToGetAll));
            NestedTypes  = EmitNestedTypes(type.GetNestedTypes(flagsToGetAll));
        }