本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxList.SelectMany方法的具体用法?C# SyntaxList.SelectMany怎么用?C# SyntaxList.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList
的用法示例。
在下文中一共展示了SyntaxList.SelectMany方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseAttributes
/// <summary>
/// Parses an attribute
/// </summary>
/// <param name="attributeLists">The list of attributes to parse</param>
/// <param name="separator">The separator to use between attributes</param>
/// <returns>A tuple where the first value is the Swift attributes and the second contains the value of an ExportAttribute</returns>
private static Tuple<string, string> ParseAttributes(SyntaxList<AttributeListSyntax> attributeLists, string separator = " ")
{
if (!attributeLists.Any()) return new Tuple<string, string>("", null);
var output = "";
string exportAs = null;
foreach (var attribute in attributeLists.SelectMany(attrList => attrList.Attributes))
{
if (IsSharpSwiftAttribute(attribute, "ExportAttribute"))
{
exportAs = SyntaxNode(attribute.ArgumentList.Arguments[0].Expression).Trim().Trim('"');
continue;
}
output += SyntaxNode(attribute) + separator;
}
return new Tuple<string, string>(output, exportAs);
}
示例2: SelectAttributeOfType
public static AttributeSyntax SelectAttributeOfType(SyntaxList<AttributeListSyntax> attributeLists, Type type, SemanticModel semanticModel)
{
return attributeLists.SelectMany(
attributeListSyntax => attributeListSyntax.Attributes)
.FirstOrDefault(
attributeSyntax =>
new AttributeInspector(attributeSyntax, semanticModel).IsAttributeTypeOf(type));
}
示例3: HasAttribute
private bool HasAttribute(SyntaxList<AttributeListSyntax> attributeLists, string attributeName)
{
return attributeLists
.SelectMany(al => al.Attributes)
.Any(a => GetSimpleNameFromNode(a).Identifier.ValueText == attributeName);
}