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

            var reference = new TypeReference(
                type.Namespace,
                type.Name,
                module,
                ImportScope(type.Scope),
                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);
        }