本文整理汇总了C#中AttributeData.DecodeNamedArgument方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeData.DecodeNamedArgument方法的具体用法?C# AttributeData.DecodeNamedArgument怎么用?C# AttributeData.DecodeNamedArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeData
的用法示例。
在下文中一共展示了AttributeData.DecodeNamedArgument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryDecodeSuppressMessageAttributeData
private static bool TryDecodeSuppressMessageAttributeData(AttributeData attribute, out SuppressMessageInfo info)
{
info = default(SuppressMessageInfo);
// We need at least the Category and Id to decode the diagnostic to suppress.
// The only SuppressMessageAttribute constructor requires those two parameters.
if (attribute.CommonConstructorArguments.Length < 2)
{
return false;
}
// Ignore the category parameter because it does not identify the diagnostic
// and category information can be obtained from diagnostics themselves.
info.Id = attribute.CommonConstructorArguments[1].Value as string;
if (info.Id == null)
{
return false;
}
// Allow an optional human-readable descriptive name on the end of an Id.
// See http://msdn.microsoft.com/en-us/library/ms244717.aspx
var separatorIndex = info.Id.IndexOf(':');
if (separatorIndex != -1)
{
info.Id = info.Id.Remove(separatorIndex);
}
info.Scope = attribute.DecodeNamedArgument<string>("Scope", SpecialType.System_String);
info.Target = attribute.DecodeNamedArgument<string>("Target", SpecialType.System_String);
info.MessageId = attribute.DecodeNamedArgument<string>("MessageId", SpecialType.System_String);
return true;
}