Ejemplo n.º 1
0
        private TypeReference CreateDeclRef(TypeReference tref, ModuleDefinition module, IInjector injector)
        {
            var declReference = new TypeReference(
                tref.Namespace,
                tref.Name,
                tref.Module,
                module.ImportScope(injector.MapMetadataScope(tref.Scope)),
                tref.IsValueType);

            MetadataSystem.TryProcessPrimitiveTypeReference(declReference);

            if (tref.ContainsGenericParameter)
                CecilHelpers.ImportGenericParameters(declReference, tref);

            if (tref.IsNested)
                declReference.DeclaringType = CreateDeclRef(tref.DeclaringType, module, injector);

            return declReference;
        }
Ejemplo n.º 2
0
        internal TypeReference Import(ModuleDefinition module, IMetadataScope scope, IInjector injector)
        {
            var reference = new TypeReference(
                ParentType == null ? Attr.Namespace : "",
                InjecteeType.Name,
                module,
                module.ImportScope(injector.MapMetadataScope(scope)),
                InjecteeType.IsValueType);

            MetadataSystem.TryProcessPrimitiveTypeReference(reference);

            if (ParentType != null)
            {
                var declDef = module.FindMatchingType(ParentType, true);
                reference.DeclaringType = CreateDeclRef(declDef, module, injector);
            }

            if (InjecteeType.ContainsGenericParameters)
                CecilHelpers.ImportGenericParameters(reference, InjecteeType);

            return reference;
        }
        private TypeReference Import(TypeReference tdef, ModuleDefinition module, IInjector injector)
        {
            if (tdef.IsTypeSpecification())
                throw new NotImplementedException();

            var reference = new TypeReference(
                tdef.Namespace,
                tdef.Name,
                module,
                module.ImportScope(injector.MapMetadataScope(tdef.Scope)),
                tdef.IsValueType);

            MetadataSystem.TryProcessPrimitiveTypeReference(reference);

            if (tdef.IsNested)
                reference.DeclaringType = Import(tdef.DeclaringType, module, injector);

            if (tdef.HasGenericParameters)
                CecilHelpers.ImportGenericParameters(reference, tdef);

            return reference;
        }