Exemplo n.º 1
0
        public static MethodBase MethodBase(MethodMetadata methodModel)
        {
            return(new MethodBase()
            {
                Name = methodModel.Name,

                Extension = methodModel.Extension,
                ReturnType = GetOrAdd(methodModel.ReturnType),

                GenericArguments = methodModel.GenericArguments?.Select(GetOrAdd).ToList(),

                Parameters = methodModel.Parameters?.Select(ParameterBase).ToList(),

                AccessLevel = methodModel.AccessLevel.ToBaseEnum(),
                AbstractEnum = methodModel.AbstractEnum.ToBaseEnum(),
                StaticEnum = methodModel.StaticEnum.ToBaseEnum(),
                VirtualEnum = methodModel.VirtualEnum.ToBaseEnum()
            });
        }
Exemplo n.º 2
0
 internal TypeMetadata(Type type)
 {
     //m_Type = type;
     m_typeName = type.Name;
     if (!m_typesMetadata.ContainsKey(this.m_typeName))
     {
         m_typesMetadata.Add(this.m_typeName, this);
     }
     m_DeclaringType         = EmitDeclaringType(type.DeclaringType);
     m_Constructors          = MethodMetadata.EmitMethods(type.GetConstructors());
     m_Methods               = MethodMetadata.EmitMethods(type.GetMethods());
     m_NestedTypes           = EmitNestedTypes(type.GetNestedTypes());
     m_ImplementedInterfaces = EmitImplements(type.GetInterfaces());
     m_GenericArguments      = !type.IsGenericTypeDefinition ? null : TypeMetadata.EmitGenericArguments(type.GetGenericArguments());
     m_Modifiers             = EmitModifiers(type);
     m_BaseType              = EmitExtends(type.BaseType);
     m_Properties            = PropertyMetadata.EmitProperties(type.GetProperties());
     m_TypeKind              = GetTypeKind(type);
     //m_Attributes = type.GetCustomAttributes(false).Cast<Attribute>();
 }
Exemplo n.º 3
0
        public TypeMetadata(BaseTypeMetadata typeMetadata)
        {
            m_typeName      = typeMetadata.TypeName;
            m_NamespaceName = typeMetadata.NamespaceName;

            if (!BaseTypeMetadata.TypeDictionary.ContainsKey(m_typeName))
            {
                BaseTypeMetadata.TypeDictionary.Add(m_typeName, typeMetadata);
            }
            if (!m_typesMetadata.ContainsKey(m_typeName))
            {
                m_typesMetadata.Add(m_typeName, this);
            }

            if (typeMetadata.BaseType != null)
            {
                if (m_typesMetadata.ContainsKey(typeMetadata.BaseType.TypeName))
                {
                    m_BaseType = m_typesMetadata[typeMetadata.BaseType.TypeName];
                }
                else
                {
                    m_BaseType = new TypeMetadata(typeMetadata.BaseType);
                }
            }

            if (typeMetadata.GenericArguments != null)
            {
                List <TypeMetadata> genericArguments = new List <TypeMetadata>();
                foreach (BaseTypeMetadata baseMetadata in typeMetadata.GenericArguments)
                {
                    TypeMetadata metadata;
                    if (m_typesMetadata.ContainsKey(baseMetadata.TypeName))
                    {
                        metadata = m_typesMetadata[baseMetadata.TypeName];
                    }
                    else
                    {
                        metadata = new TypeMetadata(baseMetadata);
                    }
                    genericArguments.Add(metadata);
                }
                m_GenericArguments = genericArguments;
            }

            m_Modifiers = typeMetadata.Modifiers;
            //TypeKind = typeMetadata.TypeKind;

            if (typeMetadata.ImplementedInterfaces != null)
            {
                List <TypeMetadata> interfaces = new List <TypeMetadata>();
                foreach (BaseTypeMetadata baseMetadata in typeMetadata.ImplementedInterfaces)
                {
                    TypeMetadata metadata;
                    if (m_typesMetadata.ContainsKey(typeMetadata.TypeName))
                    {
                        metadata = m_typesMetadata[typeMetadata.TypeName];
                    }
                    else
                    {
                        metadata = new TypeMetadata(typeMetadata);
                    }
                    interfaces.Add(metadata);
                }
                m_ImplementedInterfaces = interfaces;
            }

            if (typeMetadata.NestedTypes != null)
            {
                List <TypeMetadata> nestedTypes = new List <TypeMetadata>();
                foreach (BaseTypeMetadata baseMetadata in typeMetadata.NestedTypes)
                {
                    TypeMetadata metadata;
                    if (m_typesMetadata.ContainsKey(baseMetadata.TypeName))
                    {
                        metadata = m_typesMetadata[baseMetadata.TypeName];
                    }
                    else
                    {
                        metadata = new TypeMetadata(baseMetadata);
                    }
                    nestedTypes.Add(metadata);
                }
                m_NestedTypes = nestedTypes;
            }

            if (typeMetadata.Properties != null)
            {
                List <PropertyMetadata> properties = new List <PropertyMetadata>();
                foreach (BasePropertyMetadata baseProperty in typeMetadata.Properties)
                {
                    PropertyMetadata propertyMetadata = new PropertyMetadata(baseProperty);
                    properties.Add(propertyMetadata);
                }
                m_Properties = properties;
            }

            if (typeMetadata.DeclaringType != null)
            {
                if (m_typesMetadata.ContainsKey(typeMetadata.DeclaringType.TypeName))
                {
                    m_DeclaringType = m_typesMetadata[typeMetadata.DeclaringType.TypeName];
                }
                else
                {
                    m_DeclaringType = new TypeMetadata(typeMetadata.DeclaringType);
                }
            }

            if (typeMetadata.Methods != null)
            {
                List <MethodMetadata> methods = new List <MethodMetadata>();
                foreach (BaseMethodMetadata methodMetadata in typeMetadata.Methods)
                {
                    MethodMetadata metadata = new MethodMetadata(methodMetadata);
                    methods.Add(metadata);
                }
                m_Methods = methods;
            }

            if (typeMetadata.Constructors != null)
            {
                List <MethodMetadata> constructors = new List <MethodMetadata>();
                foreach (BaseMethodMetadata baseMetadata in typeMetadata.Constructors)
                {
                    MethodMetadata methodMetadata = new MethodMetadata(baseMetadata);
                    constructors.Add(methodMetadata);
                }
                m_Constructors = constructors;
            }

            m_TypeKind = typeMetadata.TypeKind;
        }