当前位置: 首页>>代码示例>>C#>>正文


C# GenericInstanceType.GetOriginalType方法代码示例

本文整理汇总了C#中Mono.Cecil.GenericInstanceType.GetOriginalType方法的典型用法代码示例。如果您正苦于以下问题:C# GenericInstanceType.GetOriginalType方法的具体用法?C# GenericInstanceType.GetOriginalType怎么用?C# GenericInstanceType.GetOriginalType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.GenericInstanceType的用法示例。


在下文中一共展示了GenericInstanceType.GetOriginalType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTypeSpec

		TypeSpecification GetTypeSpec (TypeSpecification original, ImportContext context)
		{
			TypeSpecification typeSpec;

			TypeReference elementType = ImportTypeReference (original.ElementType, context);
			if (original is PointerType) {
				typeSpec = new PointerType (elementType);
			} else if (original is ArrayType) { // deal with complex arrays
				typeSpec = new ArrayType (elementType);
			} else if (original is ReferenceType) {
				typeSpec = new ReferenceType (elementType);
			} else if (original is GenericInstanceType) {
				GenericInstanceType git = original as GenericInstanceType;
				GenericInstanceType genElemType = new GenericInstanceType (elementType);

				context.GenericContext.CheckProvider (genElemType.GetOriginalType (), git.GenericArguments.Count);
				foreach (TypeReference arg in git.GenericArguments)
					genElemType.GenericArguments.Add (ImportTypeReference (arg, context));

				typeSpec = genElemType;
			} else if (original is ModifierOptional) {
				TypeReference mt = (original as ModifierOptional).ModifierType;
				typeSpec = new ModifierOptional (elementType, ImportTypeReference (mt, context));
			} else if (original is ModifierRequired) {
				TypeReference mt = (original as ModifierRequired).ModifierType;
				typeSpec = new ModifierRequired (elementType, ImportTypeReference (mt, context));
			} else if (original is SentinelType) {
				typeSpec = new SentinelType (elementType);
			} else if (original is FunctionPointerType) {
				FunctionPointerType ori = original as FunctionPointerType;

				FunctionPointerType fnptr = new FunctionPointerType (
					ori.HasThis,
					ori.ExplicitThis,
					ori.CallingConvention,
					new MethodReturnType (ImportTypeReference (ori.ReturnType.ReturnType, context)));

				foreach (ParameterDefinition parameter in ori.Parameters)
					fnptr.Parameters.Add (new ParameterDefinition (ImportTypeReference (parameter.ParameterType, context)));

				typeSpec = fnptr;
			} else
				throw new ReflectionException ("Unknown element type: {0}", original.GetType ().Name);

			return typeSpec;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:46,代码来源:DefaultImporter.cs

示例2: GetTypeRefFromSig

        public TypeReference GetTypeRefFromSig(SigType t, GenericContext context)
        {
            switch (t.ElementType) {
            case ElementType.Class :
                CLASS c = t as CLASS;
                return GetTypeDefOrRef (c.Type, context);
            case ElementType.ValueType :
                VALUETYPE vt = t as VALUETYPE;
                TypeReference vtr = GetTypeDefOrRef (vt.Type, context);
                vtr.IsValueType = true;
                return vtr;
            case ElementType.String :
                return SearchCoreType (Constants.String);
            case ElementType.Object :
                return SearchCoreType (Constants.Object);
            case ElementType.Void :
                return SearchCoreType (Constants.Void);
            case ElementType.Boolean :
                return SearchCoreType (Constants.Boolean);
            case ElementType.Char :
                return SearchCoreType (Constants.Char);
            case ElementType.I1 :
                return SearchCoreType (Constants.SByte);
            case ElementType.U1 :
                return SearchCoreType (Constants.Byte);
            case ElementType.I2 :
                return SearchCoreType (Constants.Int16);
            case ElementType.U2 :
                return SearchCoreType (Constants.UInt16);
            case ElementType.I4 :
                return SearchCoreType (Constants.Int32);
            case ElementType.U4 :
                return SearchCoreType (Constants.UInt32);
            case ElementType.I8 :
                return SearchCoreType (Constants.Int64);
            case ElementType.U8 :
                return SearchCoreType (Constants.UInt64);
            case ElementType.R4 :
                return SearchCoreType (Constants.Single);
            case ElementType.R8 :
                return SearchCoreType (Constants.Double);
            case ElementType.I :
                return SearchCoreType (Constants.IntPtr);
            case ElementType.U :
                return SearchCoreType (Constants.UIntPtr);
            case ElementType.TypedByRef :
                return SearchCoreType (Constants.TypedReference);
            case ElementType.Array :
                ARRAY ary = t as ARRAY;
                return new ArrayType (GetTypeRefFromSig (ary.Type, context), ary.Shape);
            case ElementType.SzArray :
                SZARRAY szary = t as SZARRAY;
                ArrayType at = new ArrayType (GetTypeRefFromSig (szary.Type, context));
                return at;
            case ElementType.Ptr :
                PTR pointer = t as PTR;
                if (pointer.Void)
                    return new PointerType (SearchCoreType (Constants.Void));
                return new PointerType (GetTypeRefFromSig (pointer.PtrType, context));
            case ElementType.FnPtr :
                FNPTR funcptr = t as FNPTR;
                FunctionPointerType fnptr = new FunctionPointerType (funcptr.Method.HasThis, funcptr.Method.ExplicitThis,
                    funcptr.Method.MethCallConv, GetMethodReturnType (funcptr.Method, context));

                for (int i = 0; i < funcptr.Method.ParamCount; i++) {
                    Param p = funcptr.Method.Parameters [i];
                    fnptr.Parameters.Add (BuildParameterDefinition (i, p, context));
                }

                CreateSentinelIfNeeded (fnptr, funcptr.Method);

                return fnptr;
            case ElementType.Var:
                VAR var = t as VAR;
                context.CheckProvider (context.Type, var.Index + 1);

                if (context.Type is GenericInstanceType)
                    return (context.Type as GenericInstanceType).GenericArguments [var.Index];
                else
                    return context.Type.GenericParameters [var.Index];
            case ElementType.MVar:
                MVAR mvar = t as MVAR;
                context.CheckProvider (context.Method, mvar.Index + 1);

                if (context.Method is GenericInstanceMethod)
                    return (context.Method as GenericInstanceMethod).GenericArguments [mvar.Index];
                else
                    return context.Method.GenericParameters [mvar.Index];
            case ElementType.GenericInst:
                GENERICINST ginst = t as GENERICINST;
                GenericInstanceType instance = new GenericInstanceType (GetTypeDefOrRef (ginst.Type, context));
                instance.IsValueType = ginst.ValueType;
                context.CheckProvider (instance.GetOriginalType (), ginst.Signature.Arity);

                for (int i = 0; i < ginst.Signature.Arity; i++)
                    instance.GenericArguments.Add (GetGenericArg (
                        ginst.Signature.Types [i], context));

                return instance;
            default:
//.........这里部分代码省略.........
开发者ID:contra,项目名称:DotNOS,代码行数:101,代码来源:ReflectionReader.cs

示例3: GetTypeSpec

        TypeReference GetTypeSpec(TypeReference t, ImportContext context)
        {
            Stack s = new Stack ();
            while (t is TypeSpecification) {
                s.Push (t);
                t = (t as TypeSpecification).ElementType;
            }

            TypeReference elementType = ImportTypeReference (t, context);
            while (s.Count > 0) {
                t = (TypeReference) s.Pop ();
                if (t is PointerType)
                    elementType = new PointerType (elementType);
                else if (t is ArrayType) // deal with complex arrays
                    elementType = new ArrayType (elementType);
                else if (t is ReferenceType)
                    elementType = new ReferenceType (elementType);
                else if (t is GenericInstanceType) {
                    GenericInstanceType git = t as GenericInstanceType;
                    GenericInstanceType genElemType = new GenericInstanceType (elementType);

                    context.GenericContext.CheckProvider (genElemType.GetOriginalType (), git.GenericArguments.Count);
                    foreach (TypeReference arg in git.GenericArguments)
                        genElemType.GenericArguments.Add (ImportTypeReference (arg, context));

                    elementType = genElemType;
                } else
                    throw new ReflectionException ("Unknown element type: {0}", t.GetType ().Name);
            }

            return elementType;
        }
开发者ID:NALSS,项目名称:Telegraph,代码行数:32,代码来源:DefaultImporter.cs


注:本文中的Mono.Cecil.GenericInstanceType.GetOriginalType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。