本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList.Any方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxList.Any方法的具体用法?C# SyntaxList.Any怎么用?C# SyntaxList.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList
的用法示例。
在下文中一共展示了SyntaxList.Any方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetThreadStaticAttribute
private static bool TryGetThreadStaticAttribute(SyntaxList<AttributeListSyntax> attributeLists, SemanticModel semanticModel, out AttributeSyntax threadStaticAttribute)
{
threadStaticAttribute = null;
if (!attributeLists.Any())
{
return false;
}
foreach (var attributeList in attributeLists)
{
foreach (var attribute in attributeList.Attributes)
{
var attributeType = semanticModel.GetTypeInfo(attribute).Type;
if (attributeType != null &&
attributeType.ToDisplayString() == ThreadStaticAttributeName)
{
threadStaticAttribute = attribute;
return true;
}
}
}
return false;
}
示例2: HasThreadStaticAttribute
private static bool HasThreadStaticAttribute(SyntaxList<AttributeListSyntax> attributeLists, SemanticModel semanticModel)
{
if (!attributeLists.Any())
{
return false;
}
return attributeLists.Any(attributeList =>
attributeList.Attributes.Any(attribute => semanticModel.GetTypeInfo(attribute).Type.Is(KnownType.System_ThreadStaticAttribute)));
}
示例3: HasThreadStaticAttribute
private static bool HasThreadStaticAttribute(SyntaxList<AttributeListSyntax> attributeLists, SemanticModel semanticModel)
{
if (!attributeLists.Any())
{
return false;
}
return attributeLists
.Any(attributeList => attributeList.Attributes
.Select(attribute => semanticModel.GetTypeInfo(attribute).Type)
.Any(attributeType => attributeType != null &&
attributeType.ToDisplayString() == ThreadStaticAttributeName));
}
示例4: 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);
}
示例5: HasAttributes
private static bool HasAttributes(SyntaxList<AccessorDeclarationSyntax> accessors)
{
return accessors.Any(a => a.AttributeLists.Any());
}
示例6: caseStatement
private static StatementSyntax caseStatement(SyntaxList<StatementSyntax> statements)
{
Debug.Assert(statements.Any());
if (statements.Count == 1)
return statements.First();
return CSharp.Block(statements);
}
示例7: GetNewConstraintClause
private static SyntaxList<TypeParameterConstraintClauseSyntax> GetNewConstraintClause(
SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, string typeParameterName)
{
if (!constraintClauses.Any())
{
return constraintClauses;
}
var constraintList = SyntaxFactory.List<TypeParameterConstraintClauseSyntax>();
foreach (var constraint in constraintClauses)
{
var currentConstraint = constraint;
if (constraint.Name.Identifier.ValueText == typeParameterName)
{
currentConstraint = currentConstraint
.WithConstraints(
currentConstraint.Constraints.Insert(0,
SyntaxFactory.ClassOrStructConstraint(SyntaxKind.ClassConstraint)))
.WithAdditionalAnnotations(Formatter.Annotation);
}
constraintList = constraintList.Add(currentConstraint);
}
return constraintList;
}