當前位置: 首頁>>代碼示例>>C#>>正文


C# BinaryExpressionSyntax類代碼示例

本文整理匯總了C#中BinaryExpressionSyntax的典型用法代碼示例。如果您正苦於以下問題:C# BinaryExpressionSyntax類的具體用法?C# BinaryExpressionSyntax怎麽用?C# BinaryExpressionSyntax使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BinaryExpressionSyntax類屬於命名空間,在下文中一共展示了BinaryExpressionSyntax類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddIsNaNIssue

 static CodeAction AddIsNaNIssue(Document document, SemanticModel semanticModel, SyntaxNode root, BinaryExpressionSyntax node, ExpressionSyntax argExpr, string floatType)
 {
     return CodeActionFactory.Create(node.Span, DiagnosticSeverity.Warning, string.Format(node.IsKind(SyntaxKind.EqualsExpression) ? "Replace with '{0}.IsNaN(...)' call" : "Replace with '!{0}.IsNaN(...)' call", floatType), token =>
     {
         SyntaxNode newRoot;
         ExpressionSyntax expr;
         var arguments = new SeparatedSyntaxList<ArgumentSyntax>();
         arguments = arguments.Add(SyntaxFactory.Argument(argExpr));
         expr = SyntaxFactory.InvocationExpression(
             SyntaxFactory.MemberAccessExpression(
                 SyntaxKind.SimpleMemberAccessExpression,
                 SyntaxFactory.ParseExpression(floatType),
                 SyntaxFactory.IdentifierName("IsNaN")
             ),
             SyntaxFactory.ArgumentList(
                 arguments
             )
         );
         if (node.IsKind(SyntaxKind.NotEqualsExpression))
             expr = SyntaxFactory.PrefixUnaryExpression(SyntaxKind.LogicalNotExpression, expr);
         expr = expr.WithAdditionalAnnotations(Formatter.Annotation);
         newRoot = root.ReplaceNode((SyntaxNode)node, expr);
         return Task.FromResult(document.WithSyntaxRoot(newRoot));
     });
 }
開發者ID:Kavignon,項目名稱:RefactoringEssentials,代碼行數:25,代碼來源:CompareOfFloatsByEqualityOperatorCodeFixProvider.cs

示例2: GetOuterLeft

 internal static ExpressionSyntax GetOuterLeft(BinaryExpressionSyntax bop)
 {
     var leftBop = bop.Left as BinaryExpressionSyntax;
     if (leftBop != null && bop.OperatorToken.IsKind(leftBop.OperatorToken.Kind()))
         return GetOuterLeft(leftBop);
     return bop.Left;
 }
開發者ID:alecor191,項目名稱:RefactoringEssentials,代碼行數:7,代碼來源:ReplaceWithOperatorAssignmentCodeRefactoringProvider.cs

示例3: VisitBinaryExpression

        public override SyntaxNode VisitBinaryExpression(BinaryExpressionSyntax node)
        {
            var based = base.VisitBinaryExpression (node);

            if (node.Left.FindIdentifierName() == null)
                return node;

            switch (node.Kind)
            {
                case SyntaxKind.AddAssignExpression:
                case SyntaxKind.OrAssignExpression:
                case SyntaxKind.SubtractAssignExpression:
                case SyntaxKind.MultiplyAssignExpression:
                case SyntaxKind.DivideAssignExpression:
                case SyntaxKind.ModuloAssignExpression:
                case SyntaxKind.RightShiftAssignExpression:
                case SyntaxKind.LeftShiftAssignExpression:
                case SyntaxKind.AndAssignExpression:
                case SyntaxKind.ExclusiveOrAssignExpression:
                case SyntaxKind.AssignExpression:
                    return based.WithTrailingTrivia (based.GetTrailingTrivia().Prepend (GetIdComment()));

                default:
                    return node;
            }
        }
開發者ID:ermau,項目名稱:Instant,代碼行數:26,代碼來源:IdentifyingVisitor.cs

示例4: VisitBinaryExpression

        protected override SyntaxNode VisitBinaryExpression(BinaryExpressionSyntax node)
        {
            var nameSyntax = FindIdentifierName (node.Left);
            if (nameSyntax == null)
                return base.VisitBinaryExpression (node);

            switch (node.Kind)
            {
                case SyntaxKind.AddAssignExpression:
                case SyntaxKind.OrAssignExpression:
                case SyntaxKind.SubtractAssignExpression:
                case SyntaxKind.MultiplyAssignExpression:
                case SyntaxKind.DivideAssignExpression:
                case SyntaxKind.ModuloAssignExpression:
                case SyntaxKind.RightShiftAssignExpression:
                case SyntaxKind.LeftShiftAssignExpression:
                case SyntaxKind.AndAssignExpression:
                case SyntaxKind.ExclusiveOrAssignExpression:
                    var token = Syntax.Token (GetComplexAssignOperator (node.Kind));

                    ExpressionSyntax expr = Syntax.ParseExpression (nameSyntax.PlainName + token + node.Right);

                    return node.Update (node.Left, AssignToken, GetLogExpression (nameSyntax.PlainName, expr));

                case SyntaxKind.AssignExpression:
                    return node.Update (node.Left, node.OperatorToken, GetLogExpression (nameSyntax.PlainName, node.Right));

                default:
                    return base.VisitBinaryExpression (node);
            }
        }
開發者ID:Auxon,項目名稱:Instant,代碼行數:31,代碼來源:LoggingRewriter.cs

示例5: TryFlip

 static bool TryFlip(BinaryExpressionSyntax expr, out SyntaxKind flippedKind, out string operatorText)
 {
     switch (expr.Kind())
     {
         case SyntaxKind.LessThanExpression:
             flippedKind = SyntaxKind.GreaterThanExpression;
             operatorText = ">";
             return true;
         case SyntaxKind.LessThanOrEqualExpression:
             flippedKind = SyntaxKind.GreaterThanOrEqualExpression;
             operatorText = ">=";
             return true;
         case SyntaxKind.GreaterThanExpression:
             flippedKind = SyntaxKind.LessThanExpression;
             operatorText = "<";
             return true;
         case SyntaxKind.GreaterThanOrEqualExpression:
             flippedKind = SyntaxKind.LessThanOrEqualExpression;
             operatorText = "<=";
             return true;
     }
     flippedKind = SyntaxKind.None;
     operatorText = null;
     return false;
 }
開發者ID:alecor191,項目名稱:RefactoringEssentials,代碼行數:25,代碼來源:FlipRelationalOperatorArgumentsCodeRefactoringProvider.cs

示例6: BoundBinaryExpression

 public BoundBinaryExpression(BoundExpression left, BoundExpression right, BinaryOperators @operator, BinaryExpressionSyntax binaryExpressionSyntax, IType type)
     : base(binaryExpressionSyntax, type)
 {
     Left = left;
     Right = right;
     Operator = @operator;
 }
開發者ID:lawl-dev,項目名稱:Kiwi,代碼行數:7,代碼來源:BoundBinaryExpression.cs

示例7: GenerateTarget

 ExpressionSyntax GenerateTarget(SemanticModel model, BinaryExpressionSyntax node)
 {
     var symbols = model.LookupSymbols(node.SpanStart).OfType<IMethodSymbol>();
     if (!symbols.Any() || HasDifferentEqualsMethod(symbols))
         return SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, SyntaxFactory.ParseExpression("object"), SyntaxFactory.IdentifierName("Equals"));
     else
         return SyntaxFactory.IdentifierName("Equals");
 }
開發者ID:alecor191,項目名稱:RefactoringEssentials,代碼行數:8,代碼來源:ConvertEqualityOperatorToEqualsCodeRefactoringProvider.cs

示例8: PerformAction

        static Document PerformAction(Document document, SyntaxNode root, BinaryExpressionSyntax bop)
        {
            var nodeToReplace = bop.IsParentKind(SyntaxKind.ParenthesizedExpression) ? bop.Parent : bop;
            var castExpr = (ExpressionSyntax)SyntaxFactory.CastExpression(bop.Right as TypeSyntax, CSharpUtil.AddParensIfRequired(bop.Left.WithoutLeadingTrivia().WithoutTrailingTrivia())).WithLeadingTrivia(bop.GetLeadingTrivia()).WithTrailingTrivia(bop.GetTrailingTrivia());

            var newRoot = root.ReplaceNode((SyntaxNode)nodeToReplace, castExpr);
            return document.WithSyntaxRoot(newRoot);
        }
開發者ID:alecor191,項目名稱:RefactoringEssentials,代碼行數:8,代碼來源:ReplaceSafeCastWithDirectCastCodeRefactoringProvider.cs

示例9: BoundBinaryExpression

 public BoundBinaryExpression(BinaryExpressionSyntax syntax, BinaryOperatorKind operatorKind, BoundExpression left, BoundExpression right, TypeSymbol type)
     : base(BoundNodeKind.BinaryExpression, syntax)
 {
     OperatorKind = operatorKind;
     Left = left;
     Right = right;
     Type = type;
 }
開發者ID:pminiszewski,項目名稱:HlslTools,代碼行數:8,代碼來源:BoundBinaryExpression.cs

示例10: ComputeExpression

 internal static SyntaxNode ComputeExpression(SyntaxNode nodeToReplace, BinaryExpressionSyntax expression, SyntaxNode root, SemanticModel semanticModel)
 {
     var result = semanticModel.GetConstantValue(expression);
     if (!result.HasValue) return null;
     var newExpression = SyntaxFactory.ParseExpression(System.Convert.ToString(result.Value, System.Globalization.CultureInfo.InvariantCulture));
     var newRoot = root.ReplaceNode(nodeToReplace, newExpression);
     return newRoot;
 }
開發者ID:haroldhues,項目名稱:code-cracker,代碼行數:8,代碼來源:ComputeExpressionCodeFixProvider.cs

示例11: CalculateNewRoot

 private static SyntaxNode CalculateNewRoot(SyntaxNode root, BinaryExpressionSyntax currentAsBinary)
 {
     return root.ReplaceNode(currentAsBinary,
         SyntaxFactory.ConcatenateExpression(
             currentAsBinary.Left,
             SyntaxFactory.Token(SyntaxKind.AmpersandToken).WithTriviaFrom(currentAsBinary.OperatorToken),
             currentAsBinary.Right));
 }
開發者ID:dbolkensteyn,項目名稱:sonarlint-vs,代碼行數:8,代碼來源:StringConcatenationWithPlusCodeFixProvider.cs

示例12: VisitBinaryExpression

		/// <summary>
		///   Normalizes the <paramref name="binaryExpression" />.
		/// </summary>
		public override SyntaxNode VisitBinaryExpression(BinaryExpressionSyntax binaryExpression)
		{
			if (!IsFormulaType(binaryExpression))
				return base.VisitBinaryExpression(binaryExpression);

			var left = ReplaceImplicitConversion(binaryExpression.Left);
			var right = ReplaceImplicitConversion(binaryExpression.Right);
			return binaryExpression.Update(left, binaryExpression.OperatorToken, right);
		}
開發者ID:isse-augsburg,項目名稱:ssharp,代碼行數:12,代碼來源:FormulaNormalizer.cs

示例13: ChangeOperator

 private static BinaryExpressionSyntax ChangeOperator(BinaryExpressionSyntax binary)
 {
     return
         SyntaxFactory.BinaryExpression(
             OppositeExpressionKinds[binary.Kind()],
             binary.Left,
             binary.Right)
         .WithTriviaFrom(binary);
 }
開發者ID:Azzhag,項目名稱:sonarlint-vs,代碼行數:9,代碼來源:BooleanCheckInvertedCodeFixProvider.cs

示例14: AnalyzeBinaryExpression

 private static void AnalyzeBinaryExpression(BinaryExpressionSyntax node, SemanticModel model, Action<Diagnostic> addDiagnostic)
 {
     var leftType = model.GetTypeInfo(node.Left).Type;
     var rightType = model.GetTypeInfo(node.Right).Type;
     if (leftType != null && rightType != null && leftType.SpecialType == SpecialType.System_String && rightType.SpecialType == SpecialType.System_String)
     {
         addDiagnostic(node.OperatorToken.GetLocation().CreateDiagnostic(Rule));
     }
 }
開發者ID:maggiemsft,項目名稱:roslyn-analyzers,代碼行數:9,代碼來源:CSharpUseOrdinalStringComparison.cs

示例15: Go

        public static void Go(OutputWriter writer, BinaryExpressionSyntax expression)
        {
            var leftExpression = expression.Left;
            var rightExpression = expression.Right;

            var operatorToken = expression.OperatorToken;
             
            WriteIt(writer, operatorToken, rightExpression, leftExpression);
        }
開發者ID:mortezabarzkar,項目名稱:SharpNative,代碼行數:9,代碼來源:WriteBinaryExpression.cs


注:本文中的BinaryExpressionSyntax類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。