本文整理汇总了C#中Module.getAllMethods方法的典型用法代码示例。如果您正苦于以下问题:C# Module.getAllMethods方法的具体用法?C# Module.getAllMethods怎么用?C# Module.getAllMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module.getAllMethods方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: renameResourceNamesInCode
void renameResourceNamesInCode(Module module, IEnumerable<TypeInfo> renamedTypes)
{
// This is needed to speed up this method
var oldToNewTypeName = new Dictionary<string, string>(StringComparer.Ordinal);
foreach (var info in renamedTypes)
oldToNewTypeName[info.oldFullName] = info.type.TypeDefinition.FullName;
List<string> validResourceNames = new List<string>();
if (module.ModuleDefinition.Resources != null) {
foreach (var resource in module.ModuleDefinition.Resources) {
var name = resource.Name;
if (name.EndsWith(".resources", StringComparison.Ordinal))
validResourceNames.Add(name);
}
}
foreach (var method in module.getAllMethods()) {
if (!method.HasBody)
continue;
foreach (var instr in method.Body.Instructions) {
if (instr.OpCode != OpCodes.Ldstr)
continue;
var s = (string)instr.Operand;
if (string.IsNullOrEmpty(s))
continue; // Ignore emtpy strings since we'll get lots of false warnings
string newName = null;
string oldName = null;
if (oldToNewTypeName.ContainsKey(s)) {
oldName = s;
newName = oldToNewTypeName[s];
}
else if (s.EndsWith(".resources", StringComparison.Ordinal)) {
// This should rarely, if ever, execute...
foreach (var info in renamedTypes) { // Slow loop
var newName2 = renameResourceString(s, info.oldFullName, info.type.TypeDefinition.FullName);
if (newName2 != s) {
newName = newName2;
oldName = info.oldFullName;
break;
}
}
}
if (newName == null || string.IsNullOrEmpty(oldName))
continue;
bool isValid = false;
foreach (var validName in validResourceNames) {
if (Utils.StartsWith(validName, oldName, StringComparison.Ordinal)) {
isValid = true;
break;
}
}
if (!isValid)
continue;
if (s == "" || !module.ObfuscatedFile.RenameResourcesInCode)
Log.v("Possible resource name in code: '{0}' => '{1}' in method {2}", Utils.removeNewlines(s), newName, Utils.removeNewlines(method));
else {
instr.Operand = newName;
Log.v("Renamed resource string in code: '{0}' => '{1}' ({2})", Utils.removeNewlines(s), newName, Utils.removeNewlines(method));
break;
}
}
}
}