本文整理汇总了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));
}
}
}
示例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);
}
}