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


C# AssignmentExpressionSyntax.IsKind方法代码示例

本文整理汇总了C#中AssignmentExpressionSyntax.IsKind方法的典型用法代码示例。如果您正苦于以下问题:C# AssignmentExpressionSyntax.IsKind方法的具体用法?C# AssignmentExpressionSyntax.IsKind怎么用?C# AssignmentExpressionSyntax.IsKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AssignmentExpressionSyntax的用法示例。


在下文中一共展示了AssignmentExpressionSyntax.IsKind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMemberAccessExpressionFromAssignment

 private static MemberAccessExpressionSyntax GetMemberAccessExpressionFromAssignment(SemanticModel semanticModel, AssignmentExpressionSyntax assignmentExpression, AssignmentExpressionSyntax nullLiteralAssignment)
 {
     if (assignmentExpression == null || nullLiteralAssignment == null
         || !assignmentExpression.IsKind(SyntaxKind.SimpleAssignmentExpression)
         || !assignmentExpression.IsKind(SyntaxKind.SimpleAssignmentExpression))
         return null;
     if (!nullLiteralAssignment.Right.IsKind(SyntaxKind.NullLiteralExpression)) return null;
     if (!nullLiteralAssignment.Left.IsKind(SyntaxKind.IdentifierName)) return null;
     if (!assignmentExpression.Left.IsKind(SyntaxKind.IdentifierName)) return null;
     var assignmentIdentifier = semanticModel.GetSymbolInfo(assignmentExpression.Left);
     var nullLiteralAssignmentIdentifier = semanticModel.GetSymbolInfo(nullLiteralAssignment.Left);
     if ((assignmentIdentifier.Symbol ?? nullLiteralAssignmentIdentifier.Symbol) == null) return null;
     if (!assignmentIdentifier.Equals(nullLiteralAssignmentIdentifier)) return null;
     var memberAccessExpression = assignmentExpression.Right as MemberAccessExpressionSyntax;
     return memberAccessExpression;
 }
开发者ID:JeanLLopes,项目名称:code-cracker,代码行数:16,代码来源:ExistenceOperatorAnalyzer.cs

示例2: ReplaceAddExpressionByStringBuilderAppendExpression

 private static SyntaxNode ReplaceAddExpressionByStringBuilderAppendExpression(AssignmentExpressionSyntax assignmentExpression, SyntaxNode expressionStatement, SyntaxNode expressionStatementParent, string builderName)
 {
     var appendExpressionOnLoop = assignmentExpression.IsKind(SyntaxKind.SimpleAssignmentExpression)
         ? SyntaxFactory.ParseStatement($"{builderName}.Append({((BinaryExpressionSyntax)assignmentExpression.Right).Right.ToString()});\r\n")
         : SyntaxFactory.ParseStatement($"{builderName}.Append({assignmentExpression.Right.ToString()});\r\n");
     appendExpressionOnLoop = appendExpressionOnLoop
         .WithLeadingTrivia(expressionStatement.GetLeadingTrivia())
         .WithTrailingTrivia(expressionStatement.GetTrailingTrivia());
     var newExpressionStatementParent = expressionStatementParent.ReplaceNode(expressionStatement, appendExpressionOnLoop);
     return newExpressionStatementParent;
 }
开发者ID:haroldhues,项目名称:code-cracker,代码行数:11,代码来源:StringBuilderInLoopCodeFixProvider.cs

示例3: TryGetSingleAssignment

        private static bool TryGetSingleAssignment(IfStatementSyntax ifStatement, out AssignmentExpressionSyntax assignment)
        {
            assignment = null;

            var statement = ifStatement.Statement;
            var block = statement as BlockSyntax;
            if (block != null &&
                block.Statements.Count == 1)
            {
                statement = block.Statements.First();
            }
            else
            {
                return false;
            }

            assignment = (statement as ExpressionStatementSyntax)?.Expression as AssignmentExpressionSyntax;
            return assignment != null &&
                assignment.IsKind(SyntaxKind.SimpleAssignmentExpression);
        }
开发者ID:duncanpMS,项目名称:sonarlint-vs,代码行数:20,代码来源:RedundantConditionalAroundAssignment.cs


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