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

C# DotNet.MethodSig类代码示例

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

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



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

示例1: GetDelegateType

        protected static TypeDef GetDelegateType(RPContext ctx, MethodSig sig)
        {
            TypeDef ret;
            if (ctx.Delegates.TryGetValue(sig, out ret))
                return ret;

            ret = new TypeDefUser(ctx.Name.ObfuscateName(ctx.Method.DeclaringType.Namespace, RenameMode.Unicode), ctx.Name.RandomName(), ctx.Module.CorLibTypes.GetTypeRef("System", "MulticastDelegate"));
            ret.Attributes = TypeAttributes.NotPublic | TypeAttributes.Sealed;

            var ctor = new MethodDefUser(".ctor", MethodSig.CreateInstance(ctx.Module.CorLibTypes.Void, ctx.Module.CorLibTypes.Object, ctx.Module.CorLibTypes.IntPtr));
            ctor.Attributes = MethodAttributes.Assembly | MethodAttributes.HideBySig | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName;
            ctor.ImplAttributes = MethodImplAttributes.Runtime;
            ret.Methods.Add(ctor);

            var invoke = new MethodDefUser("Invoke", sig.Clone());
            invoke.MethodSig.HasThis = true;
            invoke.Attributes = MethodAttributes.Assembly | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot;
            invoke.ImplAttributes = MethodImplAttributes.Runtime;
            ret.Methods.Add(invoke);

            ctx.Module.Types.Add(ret);

            foreach (IDnlibDef def in ret.FindDefinitions()) {
                ctx.Marker.Mark(def);
                ctx.Name.SetCanRename(def, false);
            }

            ctx.Delegates[sig] = ret;
            return ret;
        }
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:30,代码来源:RPMode.cs


示例2: Create

		public static MethodDefOptions Create(UTF8String name, MethodSig methodSig) {
			return new MethodDefOptions {
				ImplAttributes = MethodImplAttributes.IL | MethodImplAttributes.Managed,
				Attributes = MethodAttributes.Public | MethodAttributes.ReuseSlot | MethodAttributes.HideBySig | (methodSig.HasThis ? 0 : MethodAttributes.Static),
				Name = name,
				MethodSig = methodSig,
				ImplMap = null,
			};
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:9,代码来源:MethodDefOptions.cs


示例3: ResolveGenericArgs

		MethodSig ResolveGenericArgs(MethodSig sig, MethodSig old) {
			sig.RetType = ResolveGenericArgs(old.RetType);
			foreach (TypeSig p in old.Params)
				sig.Params.Add(ResolveGenericArgs(p));
			sig.GenParamCount = old.GenParamCount;
			if (sig.ParamsAfterSentinel != null) {
				foreach (TypeSig p in old.ParamsAfterSentinel)
					sig.ParamsAfterSentinel.Add(ResolveGenericArgs(p));
			}
			return sig;
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:11,代码来源:GenericArgumentResolver.cs


示例4: CorPropertyInfo

		public CorPropertyInfo(CorType ownerType, uint token, uint getToken, uint setToken, string name, MethodSig getSig, MethodSig setSig, MethodAttributes getMethodAttributes, DebuggerBrowsableState? debuggerBrowsableState) {
			this.OwnerType = ownerType;
			this.Token = token;
			this.GetToken = getToken;
			this.SetToken = setToken;
			this.Name = name;
			this.GetSig = getSig;
			this.SetSig = setSig;
			this.GetMethodAttributes = getMethodAttributes;
			this.DebuggerBrowsableState = debuggerBrowsableState;
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:11,代码来源:MetaDataUtils.cs


示例5: MethodDefOptions

		public MethodDefOptions(MethodDef method) {
			this.ImplAttributes = method.ImplAttributes;
			this.Attributes = method.Attributes;
			this.Name = method.Name;
			this.MethodSig = method.MethodSig;
			this.ImplMap = method.ImplMap;
			this.CustomAttributes.AddRange(method.CustomAttributes);
			this.DeclSecurities.AddRange(method.DeclSecurities);
			this.ParamDefs.AddRange(method.ParamDefs);
			this.GenericParameters.AddRange(method.GenericParameters);
			this.Overrides.AddRange(method.Overrides);
		}
开发者ID:GreenDamTan,项目名称:dnSpy,代码行数:12,代码来源:MethodDefOptions.cs


示例6: Resolve

		/// <summary>
		///     Resolves the method signature with the specified generic arguments.
		/// </summary>
		/// <param name="methodSig">The method signature.</param>
		/// <param name="typeGenArgs">The type generic arguments.</param>
		/// <returns>Resolved method signature.</returns>
		/// <exception cref="System.ArgumentException">No generic arguments to resolve.</exception>
		public static MethodSig Resolve(MethodSig methodSig, IList<TypeSig> typeGenArgs) {
			if (typeGenArgs == null)
				throw new ArgumentException("No generic arguments to resolve.");

			var resolver = new GenericArgumentResolver();
			resolver.genericArguments = new GenericArguments();
			resolver.recursionCounter = new RecursionCounter();

			if (typeGenArgs != null)
				resolver.genericArguments.PushTypeArgs(typeGenArgs);

			return resolver.ResolveGenericArgs(methodSig);
		}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:20,代码来源:GenericArgumentResolver.cs


示例7: MethodDefOptions

		public MethodDefOptions(MethodDef method) {
			ImplAttributes = method.ImplAttributes;
			Attributes = method.Attributes;
			SemanticsAttributes = method.SemanticsAttributes;
			RVA = method.RVA;
			Name = method.Name;
			MethodSig = method.MethodSig;
			ImplMap = method.ImplMap;
			CustomAttributes.AddRange(method.CustomAttributes);
			DeclSecurities.AddRange(method.DeclSecurities);
			ParamDefs.AddRange(method.ParamDefs);
			GenericParameters.AddRange(method.GenericParameters);
			Overrides.AddRange(method.Overrides);
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:14,代码来源:MethodDefOptions.cs


示例8: MemberRefUser

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="module">Owner module</param>
		/// <param name="name">Name of method ref</param>
		/// <param name="sig">Method sig</param>
		/// <param name="class">Owner of method</param>
		public MemberRefUser(ModuleDef module, UTF8String name, MethodSig sig, IMemberRefParent @class) {
			this.module = module;
			this.name = name;
			[email protected] = @class;
			this.signature = sig;
		}
开发者ID:xingkongtianyu,项目名称:Protect.NET,代码行数:13,代码来源:MemberRef.cs


示例9: MethodSigFullName

		/// <summary>
		/// Returns the full name of a method sig
		/// </summary>
		/// <param name="methodSig">Method sig</param>
		/// <returns>Method sig full name</returns>
		public static string MethodSigFullName(MethodSig methodSig) {
			var fnc = new FullNameCreator(false, null);
			fnc.CreateMethodFullName(null, null, methodSig, null);
			return fnc.Result;
		}
开发者ID:KitoHo,项目名称:Reflexil,代码行数:10,代码来源:FullNameCreator.cs


示例10: StandAloneSigUser

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="methodSig">A method sig</param>
		public StandAloneSigUser(MethodSig methodSig) {
			this.signature = methodSig;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:7,代码来源:StandAloneSig.cs


示例11: MatchProperty

        private static bool MatchProperty(PropertyDef mCandidate, MethodSig mCandidateSig, PropertyDef mProperty)
        {
            if (mCandidate == null || mCandidateSig == null || mProperty == null)
                return false;
            if (mCandidate.Name != mProperty.Name)
                return false;

            var accMeth = mCandidate.GetMethod ?? mCandidate.SetMethod;
            if (accMeth != null && accMeth.HasOverrides)
                return false;

            if (mProperty.PropertySig == null || mCandidateSig.GenParamCount != mProperty.PropertySig.GenParamCount)
                return false;

            return new SigComparer().Equals(mCandidateSig.Params, mProperty.PropertySig.Params);
        }
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:16,代码来源:TypesHierarchyHelpers.cs


示例12: MatchMethod

        private static bool MatchMethod(MethodDef mCandidate, MethodSig mCandidateSig, MethodDef mMethod)
        {
            if (mCandidate == null || mCandidateSig == null || mMethod == null)
                return false;

            if (mCandidate.Name != mMethod.Name)
                return false;

            if (mCandidate.HasOverrides)
                return false;

            if (mCandidate.IsSpecialName != mMethod.IsSpecialName)
                return false;

            if (mCandidate.HasGenericParameters || mMethod.HasGenericParameters) {
                if (!mCandidate.HasGenericParameters || !mMethod.HasGenericParameters || mCandidate.GenericParameters.Count != mMethod.GenericParameters.Count)
                    return false;
            }

            if (mMethod.MethodSig == null || mCandidateSig.Params.Count != mMethod.MethodSig.Params.Count)
                return false;

            if (mCandidate.Parameters.Count != mMethod.Parameters.Count)
                return false;
            for (int i = 0; i < mCandidate.Parameters.Count; i++) {
                var p1 = mCandidate.Parameters[i];
                var p2 = mMethod.Parameters[i];
                if (p1.IsHiddenThisParameter != p2.IsHiddenThisParameter)
                    return false;
                if (p1.IsHiddenThisParameter)
                    continue;
                var pd1 = p1.ParamDef ?? new ParamDefUser();
                var pd2 = p2.ParamDef ?? new ParamDefUser();
                if (pd1.IsIn != pd2.IsIn || pd1.IsOut != pd2.IsOut)
                    return false;
            }

            return new SigComparer().Equals(mCandidateSig.Params, mMethod.MethodSig.Params);
        }
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:39,代码来源:TypesHierarchyHelpers.cs


示例13: MethodFullName

		/// <summary>
		/// Returns the full name of a method
		/// </summary>
		/// <param name="declaringType">Declaring type full name or <c>null</c> if none</param>
		/// <param name="name">Name of method or <c>null</c> if none</param>
		/// <param name="methodSig">Method signature</param>
		/// <param name="typeGenArgs">Type generic arguments or <c>null</c> if none</param>
		/// <param name="methodGenArgs">Method generic arguments or <c>null</c> if none</param>
		/// <returns>Method full name</returns>
		public static string MethodFullName(string declaringType, string name, MethodSig methodSig, IList<TypeSig> typeGenArgs, IList<TypeSig> methodGenArgs) {
			var fnc = new FullNameCreator(false, null);
			if (typeGenArgs != null || methodGenArgs != null)
				fnc.genericArguments = new GenericArguments();
			if (typeGenArgs != null)
				fnc.genericArguments.PushTypeArgs(typeGenArgs);
			if (methodGenArgs != null)
				fnc.genericArguments.PushMethodArgs(methodGenArgs);
			fnc.CreateMethodFullName(declaringType, name, methodSig);
			return fnc.Result;
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:20,代码来源:FullNameCreator.cs


示例14: Write

 public static void Write(this ITextOutput writer, MethodSig sig, IMethod method = null)
 {
     if (sig == null && method != null)
         sig = method.MethodSig;
     if (sig == null)
         return;
     if (sig.ExplicitThis) {
         writer.Write("instance", TextTokenType.Keyword);
         writer.WriteSpace();
         writer.Write("explicit", TextTokenType.Keyword);
         writer.WriteSpace();
     }
     else if (sig.HasThis) {
         writer.Write("instance", TextTokenType.Keyword);
         writer.WriteSpace();
     }
     sig.RetType.WriteTo(writer, ILNameSyntax.SignatureNoNamedTypeParameters);
     writer.WriteSpace();
     if (method != null) {
         if (method.DeclaringType != null) {
             method.DeclaringType.WriteTo(writer, ILNameSyntax.TypeName);
             writer.Write("::", TextTokenType.Operator);
         }
         MethodDef md = method as MethodDef;
         if (md != null && md.IsCompilerControlled) {
             writer.WriteReference(Escape(method.Name + "$PST" + method.MDToken.ToInt32().ToString("X8")), method, TextTokenHelper.GetTextTokenType(method));
         }
         else {
             writer.WriteReference(Escape(method.Name), method, TextTokenHelper.GetTextTokenType(method));
         }
     }
     MethodSpec gim = method as MethodSpec;
     if (gim != null && gim.GenericInstMethodSig != null) {
         writer.Write('<', TextTokenType.Operator);
         for (int i = 0; i < gim.GenericInstMethodSig.GenericArguments.Count; i++) {
             if (i > 0) {
                 writer.Write(',', TextTokenType.Operator);
                 writer.WriteSpace();
             }
             gim.GenericInstMethodSig.GenericArguments[i].WriteTo(writer);
         }
         writer.Write('>', TextTokenType.Operator);
     }
     writer.Write("(", TextTokenType.Operator);
     var parameters = sig.GetParameters();
     for(int i = 0; i < parameters.Count; ++i) {
         if (i > 0) {
             writer.Write(',', TextTokenType.Operator);
             writer.WriteSpace();
         }
         parameters[i].WriteTo(writer, ILNameSyntax.SignatureNoNamedTypeParameters);
     }
     writer.Write(")", TextTokenType.Operator);
 }
开发者ID:gsong2014,项目名称:dnSpy,代码行数:54,代码来源:DisassemblerHelpers.cs


示例15: Resolve

 /// <summary>
 /// Resolves the generic parameters in the specified method signature.
 /// </summary>
 /// <param name="methodSig">The method signature.</param>
 /// <returns>Resolved method signature.</returns>
 public MethodSig Resolve(MethodSig methodSig)
 {
     return ResolveGenericArgs(methodSig);
 }
开发者ID:kiootic,项目名称:MOSA-Project,代码行数:9,代码来源:GenericArgumentResolver.cs


示例16: MethodWriter

            public MethodWriter(CSharpLanguage lang, ITextOutput output, IMethod method)
            {
                this.lang = lang;
                this.output = output;
                this.typeGenericParams = null;
                this.methodGenericParams = null;
                this.methodSig = method.MethodSig;

                this.md = method as MethodDef;
                var ms = method as MethodSpec;
                var mr = method as MemberRef;
                if (ms != null) {
                    var ts = ms.Method == null ? null : ms.Method.DeclaringType as TypeSpec;
                    if (ts != null) {
                        var gp = ts.TypeSig.RemovePinnedAndModifiers() as GenericInstSig;
                        if (gp != null)
                            typeGenericParams = gp.GenericArguments;
                    }

                    var gsSig = ms.GenericInstMethodSig;
                    if (gsSig != null)
                        methodGenericParams = gsSig.GenericArguments;

                    this.md = ms.Method.ResolveMethodDef();
                }
                else if (mr != null) {
                    var ts = mr.DeclaringType as TypeSpec;
                    if (ts != null) {
                        var gp = ts.TypeSig.RemovePinnedAndModifiers() as GenericInstSig;
                        if (gp != null)
                            typeGenericParams = gp.GenericArguments;
                    }

                    this.md = mr.ResolveMethod();
                }

                if (typeGenericParams != null || methodGenericParams != null)
                    this.methodSig = GenericArgumentResolver.Resolve(methodSig, typeGenericParams, methodGenericParams);
            }
开发者ID:se7ensoft,项目名称:dnSpy,代码行数:39,代码来源:CSharpLanguage.cs


示例17:

		void ISimpleILPrinter.Write(IDecompilerOutput output, MethodSig sig) => output.Write(sig);
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:1,代码来源:SimpleILPrinter.cs


示例18: CreateBridge

        private MethodDef CreateBridge(RPContext ctx, TypeDef delegateType, FieldDef field, MethodSig sig)
        {
            var method = new MethodDefUser(ctx.Name.RandomName(), sig);
            method.Attributes = MethodAttributes.PrivateScope | MethodAttributes.Static;
            method.ImplAttributes = MethodImplAttributes.Managed | MethodImplAttributes.IL;

            method.Body = new CilBody();
            method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldsfld, field));
            for (int i = 0; i < method.Parameters.Count; i++)
                method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg, method.Parameters[i]));
            method.Body.Instructions.Add(Instruction.Create(OpCodes.Call, delegateType.FindMethod("Invoke")));
            method.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));

            delegateType.Methods.Add(method);

            ctx.Context.Registry.GetService<IMarkerService>().Mark(method);
            ctx.Name.SetCanRename(method, false);

            return method;
        }
开发者ID:Jamie-Lewis,项目名称:ConfuserEx,代码行数:20,代码来源:StrongMode.cs


示例19: VTableSignature

 internal VTableSignature(TypeSig iface, MethodSig sig, string name)
 {
     if (iface.ScopeType.ResolveTypeDefThrow().IsInterface)
         InterfaceType = iface;
     else
         InterfaceType = null;
     MethodSig = sig;
     Name = name;
 }
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:9,代码来源:VTable.cs


示例20: CorMethodInfo

		public CorMethodInfo(CorType ownerType, uint token, string name, MethodSig methodSig, MethodAttributes attrs, MethodImplAttributes implAttrs, bool compilerGeneratedAttribute) {
			this.OwnerType = ownerType;
			this.Token = token;
			this.Name = name;
			this.MethodSig = methodSig;
			this.MethodAttributes = attrs;
			this.MethodImplAttributes = implAttrs;
			this.CompilerGeneratedAttribute = compilerGeneratedAttribute;
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:9,代码来源:MetaDataUtils.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# DotNet.ModuleContext类代码示例发布时间:2022-05-26
下一篇:
C# DotNet.GenericParamContext类代码示例发布时间: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