本文整理汇总了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;
}
示例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;
}
示例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);
}