當前位置: 首頁>>代碼示例>>C#>>正文


C# Cecil.ImportGenericContext類代碼示例

本文整理匯總了C#中Mono.Cecil.ImportGenericContext的典型用法代碼示例。如果您正苦於以下問題:C# ImportGenericContext類的具體用法?C# ImportGenericContext怎麽用?C# ImportGenericContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImportGenericContext類屬於Mono.Cecil命名空間,在下文中一共展示了ImportGenericContext類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ImportType

        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;
        }
開發者ID:KonajuGames,項目名稱:cecil,代碼行數:22,代碼來源:Import.cs

示例2: ImportField

        public FieldReference ImportField(FieldReference field, ImportGenericContext context)
        {
            var declaring_type = ImportType (field.DeclaringType, context);

            context.Push (declaring_type);
            try {
                return new FieldReference {
                    Name = field.Name,
                    DeclaringType = declaring_type,
                    FieldType = ImportType (field.FieldType, context),
                };
            } finally {
                context.Pop ();
            }
        }
開發者ID:KonajuGames,項目名稱:cecil,代碼行數:15,代碼來源:Import.cs

示例3: ImportMethod

        public MethodReference ImportMethod(MethodReference method, ImportGenericContext context)
        {
            if (method.IsGenericInstance)
                return ImportMethodSpecification (method, context);

            var declaring_type = ImportType (method.DeclaringType, context);

            var reference = new MethodReference {
                Name = method.Name,
                HasThis = method.HasThis,
                ExplicitThis = method.ExplicitThis,
                DeclaringType = declaring_type,
                CallingConvention = method.CallingConvention,
            };

            if (method.HasGenericParameters)
                ImportGenericParameters (reference, method);

            context.Push (reference);
            try {
                reference.ReturnType = ImportType (method.ReturnType, context);

                if (!method.HasParameters)
                    return reference;

                var reference_parameters = reference.Parameters;

                var parameters = method.Parameters;
                for (int i = 0; i < parameters.Count; i++)
                    reference_parameters.Add (
                        new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));

                return reference;
            } finally {
                context.Pop();
            }
        }
開發者ID:KonajuGames,項目名稱:cecil,代碼行數:37,代碼來源:Import.cs

示例4: ImportTypeSpecification

        TypeReference ImportTypeSpecification(Type type, ImportGenericContext context)
        {
            if (type.IsByRef)
                return new ByReferenceType (ImportType (type.GetElementType (), context));

            if (type.IsPointer)
                return new PointerType (ImportType (type.GetElementType (), context));

            if (type.IsArray)
                return new ArrayType (ImportType (type.GetElementType (), context), type.GetArrayRank ());

            if (type.IsGenericType)
                return ImportGenericInstance (type, context);

            if (type.IsGenericParameter)
                return ImportGenericParameter (type, context);

            throw new NotSupportedException (type.FullName);
        }
開發者ID:KonajuGames,項目名稱:cecil,代碼行數:19,代碼來源:Import.cs

示例5: ImportGenericParameter

        TypeReference ImportGenericParameter(Type type, ImportGenericContext context, ISRImportMapper mapper)
        {
            if (context.IsEmpty)
                throw new InvalidOperationException ();

            if (type.DeclaringMethod != null)
                return context.MethodParameter(type.DeclaringMethod, type.GenericParameterPosition, mapper);

            if (type.DeclaringType != null)
                return context.TypeParameter(type.DeclaringType, type.GenericParameterPosition, mapper);

            throw new InvalidOperationException();
        }
開發者ID:MarkusSintonen,項目名稱:MNetInjector,代碼行數:13,代碼來源:Import.cs

示例6: ImportGenericParameter

        static TypeReference ImportGenericParameter(Type type, ImportGenericContext context)
        {
            if (context.IsEmpty)
                throw new InvalidOperationException ();

            if (type.DeclaringMethod != null)
            {
                return context.MethodParameter (type.DeclaringMethod.Name, type.GenericParameterPosition);
            }
            if (type.DeclaringType != null)
            {
                return  context.TypeParameter (NormalizedFullName (type.DeclaringType), type.GenericParameterPosition);
            }
            throw new InvalidOperationException();
        }
開發者ID:KonajuGames,項目名稱:cecil,代碼行數:15,代碼來源:Import.cs

示例7: ImportGenericInstance

        TypeReference ImportGenericInstance(Type type, ImportGenericContext context)
        {
            var element_type = ImportType (type.GetGenericTypeDefinition (), context, ImportGenericKind.Definition);
            var instance = new GenericInstanceType (element_type);
            var arguments = type.GetGenericArguments ();
            var instance_arguments = instance.GenericArguments;

            context.Push (element_type);
            try {
                for (int i = 0; i < arguments.Length; i++)
                    instance_arguments.Add (ImportType (arguments [i], context));

                return instance;
            } finally {
                context.Pop ();
            }
        }
開發者ID:KonajuGames,項目名稱:cecil,代碼行數:17,代碼來源:Import.cs

示例8: ImportType

        internal TypeReference ImportType(TypeReference type, ImportGenericContext context, 
            IImportMapper mapper)
        {
            if (type.IsTypeSpecification())
                return ImportTypeSpecification(type, context, mapper);

            var mapped = mapper.MapType(type);
            if (mapped == null)
                mapped = type;

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

            MetadataSystem.TryProcessPrimitiveTypeReference(reference);

            if (mapped.IsNested)
                reference.DeclaringType = ImportType(mapped.DeclaringType, context, mapper);

            if (mapped.HasGenericParameters)
                ImportGenericParameters(reference, mapped);

            return reference;
        }
開發者ID:MarkusSintonen,項目名稱:MNetInjector,代碼行數:27,代碼來源:Import.cs

示例9: ImportField

        internal FieldReference ImportField(FieldReference field, ImportGenericContext context,
            IImportMapper mapper)
        {
            var mapped = mapper.MapField(field);
            if (mapped == null)
                mapped = field;

            var declaring_type = ImportType(mapped.DeclaringType, context, mapper);

            context.Push (declaring_type);
            try {
                return new FieldReference {
                    Name = mapped.Name,
                    DeclaringType = declaring_type,
                    FieldType = ImportType(mapped.FieldType, context, mapper),
                };
            } finally {
                context.Pop ();
            }
        }
開發者ID:MarkusSintonen,項目名稱:MNetInjector,代碼行數:20,代碼來源:Import.cs

示例10: ImportMethodSpecification

        MethodSpecification ImportMethodSpecification(MethodReference method, ImportGenericContext context)
        {
            if (!method.IsGenericInstance)
                throw new NotSupportedException ();

            var instance = (GenericInstanceMethod) method;
            var element_method = ImportMethod (instance.ElementMethod, context);
            var imported_instance = new GenericInstanceMethod (element_method);

            var arguments = instance.GenericArguments;
            var imported_arguments = imported_instance.GenericArguments;

            for (int i = 0; i < arguments.Count; i++)
                imported_arguments.Add (ImportType (arguments [i], context));

            return imported_instance;
        }
開發者ID:KonajuGames,項目名稱:cecil,代碼行數:17,代碼來源:Import.cs

示例11: ImportGenericParameter

        static TypeReference ImportGenericParameter(Type type, ImportGenericContext context)
        {
            if (context.IsEmpty)
                throw new InvalidOperationException ();

            #if !NETFX_CORE
            if (type.DeclaringMethod != null)
                return context.MethodParameter (type.DeclaringMethod.Name, type.GenericParameterPosition);
            #else
            var typeInfo = type.GetTypeInfo();
            if (typeInfo.DeclaringMethod != null)
                return context.MethodParameter(typeInfo.DeclaringMethod.Name, type.GenericParameterPosition);
            #endif

            if (type.DeclaringType != null)
                return  context.TypeParameter (NormalizedFullName (type.DeclaringType), type.GenericParameterPosition);

            throw new InvalidOperationException();
        }
開發者ID:terurou,項目名稱:cecil,代碼行數:19,代碼來源:Import.cs


注:本文中的Mono.Cecil.ImportGenericContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。