当前位置: 首页>>代码示例>>C#>>正文


C# SyntaxList.Any方法代码示例

本文整理汇总了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;
        }
开发者ID:ozgurkayaist,项目名称:sonarlint-vs,代码行数:26,代码来源:ThreadStaticNonStaticField.cs

示例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)));
        }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:10,代码来源:ThreadStaticWithInitializer.cs

示例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));
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:13,代码来源:ThreadStaticWithInitializer.cs

示例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);
        }
开发者ID:UIKit0,项目名称:SharpSwift,代码行数:26,代码来源:MemberDeclarationParser.cs

示例5: HasAttributes

 private static bool HasAttributes(SyntaxList<AccessorDeclarationSyntax> accessors)
 {
     return accessors.Any(a => a.AttributeLists.Any());
 }
开发者ID:duncanpMS,项目名称:sonarlint-vs,代码行数:4,代码来源:PropertyToAutoProperty.cs

示例6: caseStatement

        private static StatementSyntax caseStatement(SyntaxList<StatementSyntax> statements)
        {
            Debug.Assert(statements.Any());

            if (statements.Count == 1)
                return statements.First();

            return CSharp.Block(statements);
        }
开发者ID:mpmedia,项目名称:Excess,代码行数:9,代码来源:Match.cs

示例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;
        }
开发者ID:Godin,项目名称:sonarlint-vs,代码行数:26,代码来源:GenericReadonlyFieldPropertyAssignmentCodeFixProvider.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxList.Any方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。