Exemplo n.º 1
0
        TypeReference ImportType(TypeReference type, ImportGenericContext context)
        {
            if (type.IsTypeSpecification())
            {
                return(ImportTypeSpecification(type, context));
            }

            var reference = new TypeReference(
                type.Namespace,
                type.Name,
                module,
                ImportScope(type),
                type.IsValueType);

            MetadataSystem.TryProcessPrimitiveTypeReference(reference);

            if (type.IsNested)
            {
                reference.DeclaringType = ImportType(type.DeclaringType, context);
            }

            if (type.HasGenericParameters)
            {
                ImportGenericParameters(reference, type);
            }

            return(reference);
        }
Exemplo n.º 2
0
        static TypeReference CreateReference(Type type_info, ModuleDefinition module, IMetadataScope scope)
        {
            string @namespace, name;

            SplitFullName(type_info.type_fullname, out @namespace, out name);

            var type = new TypeReference(@namespace, name, module, scope);

            MetadataSystem.TryProcessPrimitiveTypeReference(type);

            AdjustGenericParameters(type);

            var nested_names = type_info.nested_names;

            if (nested_names.IsNullOrEmpty())
            {
                return(type);
            }

            for (int i = 0; i < nested_names.Length; i++)
            {
                type = new TypeReference(string.Empty, nested_names [i], module, null)
                {
                    DeclaringType = type,
                };

                AdjustGenericParameters(type);
            }

            return(type);
        }
Exemplo n.º 3
0
 internal ModuleDefinition()
 {
     this.MetadataSystem = new MetadataSystem();
     this.token          = new MetadataToken(TokenType.Module, 1);
 }