本文整理匯總了C#中Mono.Cecil.ModuleDefinition.ContainsAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# ModuleDefinition.ContainsAttribute方法的具體用法?C# ModuleDefinition.ContainsAttribute怎麽用?C# ModuleDefinition.ContainsAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.Cecil.ModuleDefinition
的用法示例。
在下文中一共展示了ModuleDefinition.ContainsAttribute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SelectMethods
private IEnumerable<MethodDefinition> SelectMethods(ModuleDefinition moduleDefinition, string excludeAttributeName)
{
var noLogAssembly = moduleDefinition.ContainsAttribute(excludeAttributeName);
if (noLogAssembly)
{
LogInfo(string.Format("Skipping '{0}' assembly due to {1} attribute", moduleDefinition.Name, excludeAttributeName));
return Enumerable.Empty<MethodDefinition>();
}
LogInfo(string.Format("Searching for Methods in assembly ({0}).", moduleDefinition.Name));
var definitions = new HashSet<MethodDefinition>(
moduleDefinition
.Types
.Where(x => x.IsClass && !x.ContainsAttribute(excludeAttributeName))
.SelectMany(x => x.Methods)
.Where(x => ValidMethod(moduleDefinition, excludeAttributeName, x))
);
// Remove NoLogAttribute
moduleDefinition.Types.SelectMany(x => x.Methods).ToList().ForEach(x => x.RemoveAttribute(excludeAttributeName));
moduleDefinition.Types.ToList().ForEach(x => x.RemoveAttribute(excludeAttributeName));
moduleDefinition.Assembly.RemoveAttribute(excludeAttributeName);
return definitions;
}