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


C# Cecil.TypeReference類代碼示例

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


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

示例1: SwapParameterTypes

        private static void SwapParameterTypes(MethodDefinition method,
            TypeDefinition targetDependency,
            TypeReference interfaceType,
            HashSet<MethodReference> modifiedMethods)
        {
            if (method.IsAbstract || !method.HasBody)
                return;

            bool modified = false;
            var parameters = method.Parameters.Cast<ParameterDefinition>();
            foreach (var parameter in parameters)
            {
                var parameterType = parameter.ParameterType;
                if (parameterType != targetDependency)
                    continue;

                parameter.ParameterType = interfaceType;
                modified = true;
            }

            if (!modified)
                return;

            modifiedMethods.Add(method);
        }
開發者ID:philiplaureano,項目名稱:Taiji,代碼行數:25,代碼來源:SwapEmbeddedMethodTypeReferences.cs

示例2: InsertInstruction

        public void InsertInstruction()
        {
            var object_ref = new TypeReference ("System", "Object", null, false);
            var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref);
            var body = new MethodBody (method);

            var il = body.GetILProcessor ();

            var first = il.Create (OpCodes.Nop);
            var second = il.Create (OpCodes.Nop);
            var third = il.Create (OpCodes.Nop);

            body.Instructions.Add (first);
            body.Instructions.Add (third);

            Assert.IsNull (first.Previous);
            Assert.AreEqual (third, first.Next);
            Assert.AreEqual (first, third.Previous);
            Assert.IsNull (third.Next);

            body.Instructions.Insert (1, second);

            Assert.IsNull (first.Previous);
            Assert.AreEqual (second, first.Next);
            Assert.AreEqual (first, second.Previous);
            Assert.AreEqual (third, second.Next);
            Assert.AreEqual (second, third.Previous);
            Assert.IsNull (third.Next);
        }
開發者ID:peterwald,項目名稱:cecil,代碼行數:29,代碼來源:MethodBodyTests.cs

示例3: Resolve

        public static TypeDefinition Resolve(IAssemblyResolver resolver, TypeReference type)
        {
            type = type.GetElementType ();

            var scope = type.Scope;
            switch (scope.MetadataScopeType) {
            case MetadataScopeType.AssemblyNameReference:
                var assembly = resolver.Resolve ((AssemblyNameReference) scope);
                if (assembly == null)
                    return null;

                return GetType (assembly.MainModule, type);
            case MetadataScopeType.ModuleDefinition:
                return GetType ((ModuleDefinition) scope, type);
            case MetadataScopeType.ModuleReference:
                var modules = type.Module.Assembly.Modules;
                var module_ref = (ModuleReference) scope;
                for (int i = 0; i < modules.Count; i++) {
                    var netmodule = modules [i];
                    if (netmodule.Name == module_ref.Name)
                        return GetType (netmodule, type);
                }
                break;
            }

            throw new NotSupportedException ();
        }
開發者ID:peterwald,項目名稱:cecil,代碼行數:27,代碼來源:MetadataResolver.cs

示例4: EventDefinition

 public EventDefinition(string name, TypeReference eventType,
     EventAttributes attrs)
     : base(name)
 {
     m_eventType = eventType;
     m_attributes = attrs;
 }
開發者ID:leftouterjoin,項目名稱:loj-prj1,代碼行數:7,代碼來源:EventDefinition.cs

示例5:

 public Tuple<TypeDefinition, AssemblyDefinition> this[TypeReference typ, AssemblyDefinition assembly]
 {
     get
       {
     return this[typ, assembly.Name];
       }
 }
開發者ID:rubicon-oss,項目名稱:AssemblyTransformer,代碼行數:7,代碼來源:TypeDefinitionCache.cs

示例6: TypeNode

 public TypeNode(string name, string parent = "", bool builtIn = false, TypeReference type = null)
 {
     Name = name;
       Type = type;
       Parent = parent;
       BuiltIn = builtIn;
 }
開發者ID:menozz,項目名稱:mirelle,代碼行數:7,代碼來源:TypeNode.cs

示例7: addType

 public TypeDefinition addType(String sTypeNameSpace, String sTypeName, TypeAttributes taTypeAttributes,
                               TypeReference trTypeReference)
 {
     var tdNewType = new TypeDefinition(sTypeName, sTypeNameSpace, taTypeAttributes, trTypeReference);
     mainModule.Types.Add(tdNewType);
     return tdNewType;
 }
開發者ID:o2platform,項目名稱:O2.Platform.Projects.Misc_and_Legacy,代碼行數:7,代碼來源:CecilAssemblyBuilder.cs

示例8: BinaryExpression

 public BinaryExpression(BinaryOperator @operator, Expression left, Expression right,
     TypeReference expressionType, TypeSystem typeSystem, IEnumerable<Instruction> instructions, bool isOverridenOperation = false)
     : this(@operator, left, right, DetermineIsChecked(instructions), instructions, isOverridenOperation)
 {
     this.ExpressionType = expressionType;
     this.typeSystem = typeSystem;
 }
開發者ID:saravanaram,項目名稱:JustDecompileEngine,代碼行數:7,代碼來源:BinaryExpression.cs

示例9: CreateInstanceOfType

 public JSInvocationExpression CreateInstanceOfType(TypeReference type)
 {
     return JSInvocationExpression.InvokeStatic(
         Dot(new JSFakeMethod("CreateInstanceOfType", type, new[] { TypeSystem.Object }, MethodTypes)),
         new[] { new JSTypeOfExpression(type) }
     );
 }
開發者ID:c444b774,項目名稱:JSIL,代碼行數:7,代碼來源:SpecialIdentifiers.cs

示例10: Coalesce

 public JSInvocationExpression Coalesce(JSExpression left, JSExpression right, TypeReference expectedType)
 {
     return JSInvocationExpression.InvokeStatic(
         Dot("Coalesce", expectedType),
         new[] { left, right }, true
     );
 }
開發者ID:c444b774,項目名稱:JSIL,代碼行數:7,代碼來源:SpecialIdentifiers.cs

示例11: DynamicIndexerExpression

 private DynamicIndexerExpression(Expression target, ExpressionCollection indices, TypeReference expressionType, IEnumerable<Instruction> instructions)
     :base(instructions)
 {
     this.Target = target;
     this.Indices = indices;
     this.ExpressionType = expressionType;
 }
開發者ID:besturn,項目名稱:JustDecompileEngine,代碼行數:7,代碼來源:DynamicIndexerExpression.cs

示例12: PickTypeKeyword

        public static string PickTypeKeyword(TypeReference type)
        {
            // FIXME
            switch (type.FullName) {
                case "System.Void":
                    return "void";

                case "System.Boolean":
                case "System.Int32":
                case "System.UInt32":
                    return "i32";

                case "System.Int64":
                case "System.UInt64":
                    return "i64";

                case "System.Single":
                    return "f32";

                case "System.Double":
                    return "f64";

                case "System.Byte":
                case "System.UInt16":
                case "System.SByte":
                case "System.Int16":
                    return "i32";
            }

            return null;
        }
開發者ID:nanexcool,項目名稱:ilwasm,代碼行數:31,代碼來源:Util.cs

示例13: ShouldAddCast

		private bool ShouldAddCast(Expression argument, List<MethodDefinition> sameNameMethods, int argumentIndex, TypeReference calledMethodParamType)
		{
			if (!argument.HasType)
			{
				return true;
			}
			TypeReference expressionType = argument.ExpressionType;
			//if (argument.ExpressionType.IsGenericParameter)
			//{
			//	return false;
			//}
			foreach (MethodDefinition method in sameNameMethods)
			{
				TypeReference parameterType = method.Parameters[argumentIndex].ParameterType;
				if (IsTypeDescendantOf(calledMethodParamType, parameterType) || calledMethodParamType.FullName == parameterType.FullName)
				{
					/// Either the called method has more specific type,
					/// or the types match.
					continue;
				}
				if (IsTypeDescendantOf(expressionType, parameterType) || expressionType.FullName == parameterType.FullName)
				{
					return true;
				}
				if (argument.CodeNodeType == CodeNodeType.LiteralExpression && ((LiteralExpression)argument).Value == null)
				{
					if (!parameterType.IsValueType)
					{
						return true;
					}
				}
			}
			return false;
		}
開發者ID:Feng2012,項目名稱:JustDecompileEngine,代碼行數:34,代碼來源:FixMethodOverloadsStep.cs

示例14: FindDerivedFrom

 public void FindDerivedFrom(TypeReference baseTypeRef)
 {
     foreach (var td in _module.Types) {
         if(IsDerivedFrom(td, baseTypeRef))
             Console.WriteLine (td.FullName);
     }
 }
開發者ID:rzaitov,項目名稱:MonotouchDisHelper,代碼行數:7,代碼來源:ModuleHandler.cs

示例15: ArrayCreationExpression

		public ArrayCreationExpression(TypeReference type, InitializerExpression initializer, IEnumerable<Instruction> instructions)
            :base(instructions)
		{
            this.ElementType = type;
            this.Initializer = initializer;
            this.Dimensions = new ExpressionCollection();
        }
開發者ID:Feng2012,項目名稱:JustDecompileEngine,代碼行數:7,代碼來源:ArrayCreationExpression.cs


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