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


C# INameService.ReduceRenameMode方法代码示例

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


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

示例1: Analyze

        public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
        {
            var module = def as ModuleDef;
            if (module == null) return;

            string asmName = module.Assembly.Name.String;
            if (!string.IsNullOrEmpty(module.Assembly.Culture) &&
                asmName.EndsWith(".resources")) {
                // Satellite assembly
                var satellitePattern = new Regex(string.Format("^(.*)\\.{0}\\.resources$", module.Assembly.Culture));
                string nameAsmName = asmName.Substring(0, asmName.Length - ".resources".Length);
                ModuleDef mainModule = context.Modules.SingleOrDefault(mod => mod.Assembly.Name == nameAsmName);
                if (mainModule == null) {
                    context.Logger.ErrorFormat("Could not find main assembly of satellite assembly '{0}'.", module.Assembly.FullName);
                    throw new ConfuserException(null);
                }

                string format = "{0}." + module.Assembly.Culture + ".resources";
                foreach (Resource res in module.Resources) {
                    Match match = satellitePattern.Match(res.Name);
                    if (!match.Success)
                        continue;
                    string typeName = match.Groups[1].Value;
                    TypeDef type = mainModule.FindReflectionThrow(typeName);
                    if (type == null) {
                        context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
                        continue;
                    }
                    service.ReduceRenameMode(type, RenameMode.ASCII);
                    service.AddReference(type, new ResourceReference(res, type, format));
                }
            }
            else {
                string format = "{0}.resources";
                foreach (Resource res in module.Resources) {
                    Match match = ResourceNamePattern.Match(res.Name);
                    if (!match.Success)
                        continue;
                    string typeName = match.Groups[1].Value;

                    if (typeName.EndsWith(".g")) // WPF resources, ignore
                        continue;

                    TypeDef type = module.FindReflection(typeName);
                    if (type == null) {
                        context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName);
                        continue;
                    }
                    service.ReduceRenameMode(type, RenameMode.ASCII);
                    service.AddReference(type, new ResourceReference(res, type, format));
                }
            }
        }
开发者ID:MulleDK19,项目名称:ConfuserEx,代码行数:53,代码来源:ResourceAnalyzer.cs

示例2: AnalyzeCAArgument

 void AnalyzeCAArgument(ConfuserContext context, INameService service, CAArgument arg)
 {
     if (arg.Type.DefinitionAssembly.IsCorLib() && arg.Type.FullName == "System.Type") {
         var typeSig = (TypeSig)arg.Value;
         foreach (ITypeDefOrRef typeRef in typeSig.FindTypeRefs()) {
             TypeDef typeDef = typeRef.ResolveTypeDefThrow();
             if (context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
                 if (typeRef is TypeRef)
                     service.AddReference(typeDef, new TypeRefReference((TypeRef)typeRef, typeDef));
                 service.ReduceRenameMode(typeDef, RenameMode.ASCII);
             }
         }
     }
     else if (arg.Value is CAArgument[]) {
         foreach (CAArgument elem in (CAArgument[])arg.Value)
             AnalyzeCAArgument(context, service, elem);
     }
 }
开发者ID:MetSystem,项目名称:ConfuserEx,代码行数:18,代码来源:TypeBlobAnalyzer.cs


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