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


C# ImportGenericContext.TypeParameter方法代碼示例

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


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

示例1: ImportTypeSpecification

        TypeReference ImportTypeSpecification(TypeReference type, ImportGenericContext context)
        {
            switch (type.etype) {
            case ElementType.SzArray:
                var vector = (ArrayType) type;
                return new ArrayType (ImportType (vector.ElementType, context));
            case ElementType.Ptr:
                var pointer = (PointerType) type;
                return new PointerType (ImportType (pointer.ElementType, context));
            case ElementType.ByRef:
                var byref = (ByReferenceType) type;
                return new ByReferenceType (ImportType (byref.ElementType, context));
            case ElementType.Pinned:
                var pinned = (PinnedType) type;
                return new PinnedType (ImportType (pinned.ElementType, context));
            case ElementType.Sentinel:
                var sentinel = (SentinelType) type;
                return new SentinelType (ImportType (sentinel.ElementType, context));
            case ElementType.CModOpt:
                var modopt = (OptionalModifierType) type;
                return new OptionalModifierType (
                    ImportType (modopt.ModifierType, context),
                    ImportType (modopt.ElementType, context));
            case ElementType.CModReqD:
                var modreq = (RequiredModifierType) type;
                return new RequiredModifierType (
                    ImportType (modreq.ModifierType, context),
                    ImportType (modreq.ElementType, context));
            case ElementType.Array:
                var array = (ArrayType) type;
                var imported_array = new ArrayType (ImportType (array.ElementType, context));
                if (array.IsVector)
                    return imported_array;

                var dimensions = array.Dimensions;
                var imported_dimensions = imported_array.Dimensions;

                imported_dimensions.Clear ();

                for (int i = 0; i < dimensions.Count; i++) {
                    var dimension = dimensions [i];

                    imported_dimensions.Add (new ArrayDimension (dimension.LowerBound, dimension.UpperBound));
                }

                return imported_array;
            case ElementType.GenericInst:
                var instance = (GenericInstanceType) type;
                var element_type = ImportType (instance.ElementType, context);
                var imported_instance = new GenericInstanceType (element_type);

                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;
            case ElementType.Var:
                var var_parameter = (GenericParameter) type;
                return context.TypeParameter (type.DeclaringType.FullName, var_parameter.Position);
            case ElementType.MVar:
                var mvar_parameter = (GenericParameter) type;
                return context.MethodParameter (mvar_parameter.DeclaringMethod.Name, mvar_parameter.Position);
            case ElementType.FnPtr:
                var funcPtr = (FunctionPointerType)type;
                var imported = new FunctionPointerType() {
                    HasThis = funcPtr.HasThis,
                    ExplicitThis = funcPtr.ExplicitThis,
                    CallingConvention = funcPtr.CallingConvention,
                    ReturnType = ImportType (funcPtr.ReturnType, context)
                };
                var parameters = funcPtr.Parameters;
                for (int i = 0; i < parameters.Count; i++)
                    imported.Parameters.Add(
                        new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));
                return imported;
            }

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

示例2: 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

示例3: 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

示例4: 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.TypeParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。