当前位置: 首页>>代码示例>>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;未经允许,请勿转载。