• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cecil.TypeReference类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TypeReference类属于Mono.Cecil命名空间,在下文中一共展示了TypeReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: create

        public string create(TypeReference typeRef)
        {
            if (typeRef.IsGenericInstance) {
                var git = (GenericInstanceType)typeRef;
                if (git.ElementType.FullName == "System.Nullable`1" &&
                    git.GenericArguments.Count == 1 && git.GenericArguments[0] != null) {
                    typeRef = git.GenericArguments[0];
                }
            }

            string prefix = getPrefix(typeRef);

            var elementType = typeRef.GetElementType();
            if (elementType is GenericParameter)
                return genericParamNameCreator.create();

            NameCreator nc;
            var typeFullName = typeRef.FullName;
            if (typeNames.TryGetValue(typeFullName, out nc))
                return nc.create();

            var name = elementType.FullName;
            var parts = name.Replace('/', '.').Split(new char[] { '.' });
            var newName = parts[parts.Length - 1];
            int tickIndex = newName.LastIndexOf('`');
            if (tickIndex > 0)
                newName = newName.Substring(0, tickIndex);

            return addTypeName(typeFullName, newName, prefix).create();
        }
开发者ID:Perplexity,项目名称:de4dot,代码行数:30,代码来源:TypeNames.cs


示例17: ContainsPositionalGenericParameter

        public static bool ContainsPositionalGenericParameter(TypeReference type)
        {
            type = DereferenceType(type);

            var gp = type as GenericParameter;
            var git = type as GenericInstanceType;
            var at = type as ArrayType;
            var byref = type as ByReferenceType;

            if (gp != null)
                return IsPositionalGenericParameter(gp);

            if (git != null) {
                var elt = git.ElementType;

                foreach (var ga in git.GenericArguments) {
                    if (IsPositionalGenericParameter(ga))
                        return true;
                }

                return IsPositionalGenericParameter(elt);
            }

            if (at != null)
                return IsPositionalGenericParameter(at.ElementType);

            if (byref != null)
                return IsPositionalGenericParameter(byref.ElementType);

            return false;
        }
开发者ID:simon-heinen,项目名称:JSIL,代码行数:31,代码来源:TypeUtil.cs


示例18: MethodDefinition

 public MethodDefinition(string name, MethodAttributes attributes, TypeReference returnType)
     : base(name, returnType)
 {
     this.attributes = (ushort) attributes;
     this.HasThis = !this.IsStatic;
     this.token = new MetadataToken (TokenType.Method);
 }
开发者ID:bladecoding,项目名称:cecil,代码行数:7,代码来源:MethodDefinition.cs


示例19: ResolveGenericParameters

 private TypeReference ResolveGenericParameters(TypeReference typeReference)
 {
     if (typeReference.IsGenericParameter)
     {
         GenericParameter parameter = (GenericParameter) typeReference;
         return Enumerable.ElementAt<TypeReference>(this.GenericArguments, parameter.Position);
     }
     if (typeReference.IsGenericInstance)
     {
         GenericInstanceType type = (GenericInstanceType) typeReference;
         GenericInstanceType type2 = new GenericInstanceType(this.ResolveGenericParameters(type.ElementType));
         foreach (TypeReference reference2 in type.GenericArguments)
         {
             type2.GenericArguments.Add(this.ResolveGenericParameters(reference2));
         }
         return type2;
     }
     if (typeReference.IsArray)
     {
         ArrayType type3 = (ArrayType) typeReference;
         return new ArrayType(this.ResolveGenericParameters(type3.ElementType), type3.Rank);
     }
     if (typeReference.IsPointer)
     {
         return new PointerType(this.ResolveGenericParameters(((PointerType) typeReference).ElementType));
     }
     if (typeReference.IsByReference)
     {
         return new ByReferenceType(this.ResolveGenericParameters(((ByReferenceType) typeReference).ElementType));
     }
     return typeReference;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:32,代码来源:GenericFieldTypeResolver.cs


示例20: createMethod

 public MethodDefinition createMethod(String sMethodName, MethodAttributes maMethodAttributes,
                                      TypeReference trReturnType)
 {
     var newMethod = new MethodDefinition(sMethodName, maMethodAttributes, trReturnType);
     newMethod.Body.CilWorker.Emit(OpCodes.Ret);
     return newMethod;
 }
开发者ID:o2platform,项目名称:O2.Platform.Projects.Misc_and_Legacy,代码行数:7,代码来源:CecilAssemblyBuilder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cecil.TypeSystem类代码示例发布时间:2022-05-26
下一篇:
C# Cecil.TypeDefinition类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap