當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。