public static bool TryCreate( ConditionalExpressionSyntax conditionalExpression, out ConditionalExpressionInfo result, bool allowNullOrMissing = false, bool walkDownParentheses = true) { if (conditionalExpression != null) { ExpressionSyntax condition = conditionalExpression.Condition?.WalkDownParenthesesIf(walkDownParentheses); if (CheckNode(allowNullOrMissing, condition)) { ExpressionSyntax whenTrue = conditionalExpression.WhenTrue?.WalkDownParenthesesIf(walkDownParentheses); if (CheckNode(allowNullOrMissing, whenTrue)) { ExpressionSyntax whenFalse = conditionalExpression.WhenFalse?.WalkDownParenthesesIf(walkDownParentheses); if (CheckNode(allowNullOrMissing, whenFalse)) { result = new ConditionalExpressionInfo(condition, whenTrue, whenFalse); return(true); } } } } result = default(ConditionalExpressionInfo); return(false); }
public static bool TryCreate( SyntaxNode node, out ConditionalExpressionInfo result, bool allowNullOrMissing = false, bool walkDownParentheses = true) { ExpressionSyntax expression = (node as ExpressionSyntax)?.WalkDownParenthesesIf(walkDownParentheses); if (expression?.IsKind(SyntaxKind.ConditionalExpression) == true) { return(TryCreate((ConditionalExpressionSyntax)expression, out result, allowNullOrMissing: allowNullOrMissing, walkDownParentheses: walkDownParentheses)); } result = default(ConditionalExpressionInfo); return(false); }