当前位置: 首页>>代码示例>>C#>>正文


C# MethodDefinition.SetName方法代码示例

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


在下文中一共展示了MethodDefinition.SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Rename

 /// <summary>
 /// Rename the given method and all references to it from code.
 /// </summary>
 private void Rename(MethodDefinition method, string newName)
 {
     methodReferences = methodReferences ?? InterfaceHelper.GetReachableMethodReferencesByName(reachableMethods);
     var resolver = new GenericsResolver(method.DeclaringType);
     foreach (var methodRef in methodReferences[method.Name])
     {
         if (ReferenceEquals(method, methodRef))
             continue;
         if (methodRef.AreSameIncludingDeclaringType(method, resolver.Resolve))
         {
             methodRef.Name = newName;
         }
     }
     method.SetName(newName);
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:18,代码来源:MethodExplicitInterfaceConverter.cs

示例2: Rename

        /// <summary>
        /// Rename the given method and all references to it from code.
        /// 
        /// Note that the passed lookup will not be accurate after completion of this method.
        /// If you rename methods multiple times, but know that you will rename each single method
        /// only once, this should not be a problem.
        /// </summary>
        public static void Rename(MethodDefinition method, string newName, ILookup<string, MethodReference> reachableMethodReferencesByMethodName)
        {
            var resolver = new GenericsResolver(method.DeclaringType);

            // Rename reference to method
            foreach (var methodRef in reachableMethodReferencesByMethodName[method.Name])
            {
                if (!ReferenceEquals(methodRef, method) && methodRef.AreSameIncludingDeclaringType(method, resolver.Resolve))
                {
                    methodRef.Name = newName;
                }
            }
            // Rename method itself
            method.SetName(newName);
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:22,代码来源:InterfaceHelper.cs


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