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


C# TypeReference.GetType方法代码示例

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


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

示例1: AreSame

        public static bool AreSame(TypeReference a, TypeReference b)
        {
            if (a.IsGenericParameter || b.IsGenericParameter)
            {
                return true;
            }
                //return AreSame((GenericParameter)a, (GenericParameter)b);

            if (a.MetadataType != b.MetadataType)
               return false;

            if (a is TypeSpecification || b is TypeSpecification)
            {
                if (a.GetType() != b.GetType())
                    return false;

                return AreSame((TypeSpecification)a, (TypeSpecification)b);
            }

            return a.FullName == b.FullName;
        }
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:21,代码来源:Helper.cs

示例2: Resolve

 /// <summary>
 /// This method resolves a type. This method ignores the methods and fields. You have to
 /// resolve them manually.
 /// </summary>
 /// <param name="hostModule">The module in which the changes are made.</param>
 /// <param name="type">The type to resolve.</param>
 /// <param name="AddedClasses">Newly added classes to lookup while resolving.</param>
 /// <param name="TypesMap">A map of types to lookup while resolving.</param>
 /// <returns></returns>
 protected static TypeReference Resolve(
     ModuleDefinition hostModule,
     TypeReference type,
     Dictionary<TypeReference, TypeDefinition> AddedClasses,
     Dictionary<TypeReference, TypeReference> TypesMap)
 {
     if (type is GenericInstanceType)
     {
         GenericInstanceType gType = (GenericInstanceType)type;
         GenericInstanceType nType = new GenericInstanceType(Resolve(hostModule, gType.ElementType, AddedClasses, TypesMap));
         foreach (TypeReference t in gType.GenericArguments)
         {
             nType.GenericArguments.Add(Resolve(hostModule, t, AddedClasses, TypesMap));
         }
         return nType;
     }
     if (type == null || type is GenericParameter || (type.IsArray && type.GetElementType() is GenericParameter))
         return type;
     if (TypesMap.ContainsKey(type))
         return hostModule.Import(TypesMap[type]);
     foreach (TypeReference addedType in AddedClasses.Keys)
     {
         if (addedType == type)
         {
             return hostModule.Import(AddedClasses[addedType]);
         }
     }
     if (type.Module != hostModule)
     {
         TypeDefinition t = hostModule.GetType(type.FullName);
         if (t != null)
         {
             return (TypeReference)t;
         }
         if (hostModule == null || type == null)
             return type;
         else
         {
             try
             {
                 return hostModule.Import(type);
             }
             catch (Exception e)
             {
                 System.Console.WriteLine(type.GetElementType());
                 System.Console.WriteLine(type.GetType().FullName);
                 throw e;
             }
         }
     }
     else
         return type;
 }
开发者ID:hamada147,项目名称:ModAPI,代码行数:62,代码来源:MonoHelper.cs

示例3: TypeMatch

        public static bool TypeMatch(TypeReference a, TypeReference b)
        {
            if (a is GenericParameter)
                return true;

            if (a is TypeSpecification || b is TypeSpecification) {
                if (a.GetType () != b.GetType ())
                    return false;

                return TypeMatch ((TypeSpecification) a, (TypeSpecification) b);
            }

            return a.FullName == b.FullName;
        }
开发者ID:yudhitech,项目名称:xamarin-macios,代码行数:14,代码来源:StaticRegistrar.cs

示例4: TypeMatch

		static bool TypeMatch (TypeReference a, TypeReference b, ref Dictionary<string,string> gp)
		{
			var gpa = a as GenericParameter;
			if (gpa != null) {
				if (gp == null)
					gp = new Dictionary<string, string> ();
				string match;
				if (!gp.TryGetValue (gpa.FullName, out match)) {
					// first use, we assume it will always be used this way
					gp.Add (gpa.FullName, b.ToString ());
					return true;
				}
				// re-use, it should match the previous usage
				return match == b.ToString ();
			}

			if (a is TypeSpecification || b is TypeSpecification) {
				if (a.GetType () != b.GetType ())
					return false;

				return TypeMatch ((TypeSpecification) a, (TypeSpecification) b, ref gp);
			}

			return a.FullName == b.FullName;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:25,代码来源:TypeMapStep.cs

示例5: TypeMatch

        static bool TypeMatch(TypeReference a, TypeReference b)
        {
            if (a is GenericParameter)
                return true; // not exact, but a guess is enough for us

            if (a is TypeSpecification || b is TypeSpecification)
            {
                if (a.GetType() != b.GetType())
                    return false;

                return TypeMatch((TypeSpecification)a, (TypeSpecification)b);
            }

            return a.FullName == b.FullName;
        }
开发者ID:adrianrus,项目名称:il-repack,代码行数:15,代码来源:ReflectionHelper.cs

示例6: typeReferenceHashCode

        // a must be exactly a TypeReference or a TypeDefinition
        static int typeReferenceHashCode(TypeReference a)
        {
            if (a == null)
                return 0;

            if (a.GetType() != typeof(TypeReference) && a.GetType() != typeof(TypeDefinition))
                throw new ApplicationException("arg must be exactly of type TypeReference or TypeDefinition");

            int res = 0;

            res += a.Name.GetHashCode();
            res += a.Namespace.GetHashCode();
            res += typeHashCode(a.DeclaringType);
            res += scopeHashCode(a.Scope);

            return res;
        }
开发者ID:ldh0227,项目名称:de4dot,代码行数:18,代码来源:MemberReferenceHelper.cs

示例7: compareTypeReferences

        // a and b must be either exactly a TypeReference or exactly a TypeDefinition
        static bool compareTypeReferences(TypeReference a, TypeReference b)
        {
            if ((a.GetType() != typeof(TypeReference) && a.GetType() != typeof(TypeDefinition)) ||
                (b.GetType() != typeof(TypeReference) && b.GetType() != typeof(TypeDefinition)))
                throw new ApplicationException("arg must be exactly of type TypeReference or TypeDefinition");

            if (ReferenceEquals(a, b))
                return true;

            return a.Name == b.Name &&
                a.Namespace == b.Namespace &&
                compareTypes(a.DeclaringType, b.DeclaringType) &&
                compareScope(a.Scope, b.Scope);
        }
开发者ID:ldh0227,项目名称:de4dot,代码行数:15,代码来源:MemberReferenceHelper.cs

示例8: compareTypes

        public static bool compareTypes(TypeReference a, TypeReference b)
        {
            if (ReferenceEquals(a, b))
                return true;
            if (a == null || b == null)
                return false;

            var atype = a.GetType();
            var btype = b.GetType();
            if (atype != btype) {
                if ((atype == typeof(TypeReference) || atype == typeof(TypeDefinition)) &&
                    (btype == typeof(TypeReference) || btype == typeof(TypeDefinition)))
                    return compareTypeReferences(a, b);
                return false;
            }

            var type = getMemberReferenceType(a);
            switch (type) {
            case CecilType.ArrayType:
                return compareArrayTypes((ArrayType)a, (ArrayType)b);
            case CecilType.ByReferenceType:
                return compareByReferenceTypes((ByReferenceType)a, (ByReferenceType)b);
            case CecilType.FunctionPointerType:
                return compareFunctionPointerTypes((FunctionPointerType)a, (FunctionPointerType)b);
            case CecilType.GenericInstanceType:
                return compareGenericInstanceTypes((GenericInstanceType)a, (GenericInstanceType)b);
            case CecilType.GenericParameter:
                return compareGenericParameters((GenericParameter)a, (GenericParameter)b);
            case CecilType.OptionalModifierType:
                return compareOptionalModifierTypes((OptionalModifierType)a, (OptionalModifierType)b);
            case CecilType.PinnedType:
                return comparePinnedTypes((PinnedType)a, (PinnedType)b);
            case CecilType.PointerType:
                return comparePointerTypes((PointerType)a, (PointerType)b);
            case CecilType.RequiredModifierType:
                return compareRequiredModifierTypes((RequiredModifierType)a, (RequiredModifierType)b);
            case CecilType.SentinelType:
                return compareSentinelTypes((SentinelType)a, (SentinelType)b);
            case CecilType.TypeDefinition:
                return compareTypeDefinitions((TypeDefinition)a, (TypeDefinition)b);
            case CecilType.TypeReference:
                return compareTypeReferences((TypeReference)a, (TypeReference)b);
            default:
                throw new ApplicationException(string.Format("Unknown cecil type {0}", type));
            }
        }
开发者ID:ldh0227,项目名称:de4dot,代码行数:46,代码来源:MemberReferenceHelper.cs

示例9: AreSame

		static bool AreSame (TypeReference a, TypeReference b)
		{
			while (a is TypeSpecification || b is TypeSpecification) {
				if (a.GetType () != b.GetType ())
					return false;

				a = ((TypeSpecification) a).ElementType;
				b = ((TypeSpecification) b).ElementType;
			}

			if (a is GenericParameter || b is GenericParameter) {
				if (a.GetType() != b.GetType())
					return false;

				GenericParameter pa = (GenericParameter) a;
				GenericParameter pb = (GenericParameter) b;

				return pa.Position == pb.Position;
			}

			return a.FullName == b.FullName;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:22,代码来源:CecilTypeResolver.cs

示例10: AreSame

		static bool AreSame (TypeReference a, TypeReference b)
		{
			if (a is TypeSpecification || b is TypeSpecification) {
				if (a.GetType () != b.GetType ())
					return false;

				return AreSame ((TypeSpecification) a, (TypeSpecification) b);
			}

			if (a is GenericParameter || b is GenericParameter) {
				if (a.GetType () != b.GetType ())
					return false;

				return AreSame ((GenericParameter) a, (GenericParameter) b);
			}

			return a.FullName == b.FullName;
		}
开发者ID:transformersprimeabcxyz,项目名称:cecil-old,代码行数:18,代码来源:MetadataResolver.cs

示例11: DoValidateRoot

        private void DoValidateRoot(string label, TypeReference type)
        {
            string mesg = null;

            if (type != null)
            {
                if (type is TypeSpecification)
                    mesg = string.Format("{0} is a {1} ({2})", label, type.GetType(), type.FullName);

                else
                    // Probably not neccesary to do these checks but it shouldn't hurt.
                    DoValidateRoot(label, type.FullName);
            }

            if (mesg != null)
                Contract.Assert(false, mesg);
        }
开发者ID:andyhebear,项目名称:Continuum,代码行数:17,代码来源:ParseAssembly.cs

示例12: 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 = s.Pop () as TypeReference;
                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);
                    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:KenMacD,项目名称:deconfuser,代码行数:30,代码来源:ReflectionHelper.cs

示例13: DumpType

 public static void DumpType(TypeReference type)
 {
     TraceVerbose("TYPE DUMP: {0}: {1}", type, type.GetType());
       DumpGenericParameters(type);
       DumpGenericArguments(type);
 }
开发者ID:cessationoftime,项目名称:nroles,代码行数:6,代码来源:Tracer.cs

示例14: AssertTypeReferencesAreIdentical

 private void AssertTypeReferencesAreIdentical(TypeReference expected, TypeReference actual)
 {
     Assert.Equal(expected.GetType(), actual.GetType());
     this.AssertGenericParametersAreIdentical(expected, actual);
     if (expected is GenericInstanceType)
     {
         this.AssertGenericArgumentsAreIdentical((GenericInstanceType)expected, (GenericInstanceType)actual);
     }
 }
开发者ID:hach-que,项目名称:Dx,代码行数:9,代码来源:ProcessorUtilities.cs

示例15: IsMatch

        public static bool IsMatch(TypeReference a, TypeReference b)
        {
            if (a is TypeSpecification || b is TypeSpecification) {
            if (a.GetType() != b.GetType()) {
              return false;
            }
            return IsMatch((TypeSpecification)a, (TypeSpecification)b);
              }

              if (a is GenericParameter || b is GenericParameter) {
            if (a.GetType() != b.GetType()) {
              return false;
            }
              }

              return a.FullName == b.FullName;
        }
开发者ID:cessationoftime,项目名称:nroles,代码行数:17,代码来源:matchers.cs


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