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


C# BinaryExpressionSyntax.Validate方法代碼示例

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


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

示例1: VisitBinaryExpression

        public void VisitBinaryExpression(BinaryExpressionSyntax node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            node.Validate();

            ExpressionStart(node);

            node.Left.Accept(this);

            bool writeSpace;
            bool wrap = false;

            switch (node.Operator)
            {
                case BinaryOperator.AsKeyword:
                case BinaryOperator.IsKeyword:
                    writeSpace = true;
                    break;

                case BinaryOperator.AmpersandEquals:
                case BinaryOperator.AsteriskEquals:
                case BinaryOperator.BarEquals:
                case BinaryOperator.CaretEquals:
                case BinaryOperator.Equals:
                case BinaryOperator.GreaterThanGreaterThanEquals:
                case BinaryOperator.LessThanLessThanEquals:
                case BinaryOperator.MinusEquals:
                case BinaryOperator.PercentEquals:
                case BinaryOperator.PlusEquals:
                case BinaryOperator.SlashEquals:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.AssignmentOperators;
                    break;

                case BinaryOperator.AmpersandAmpersand:
                case BinaryOperator.BarBar:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.LogicalOperators;
                    wrap = _wrapCompound;
                    break;

                case BinaryOperator.EqualsEquals:
                case BinaryOperator.ExclamationEquals:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.EqualityOperators;
                    break;

                case BinaryOperator.GreaterThan:
                case BinaryOperator.GreaterThanEquals:
                case BinaryOperator.LessThan:
                case BinaryOperator.LessThanEquals:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.RelationalOperators;
                    break;

                case BinaryOperator.Ampersand:
                case BinaryOperator.Bar:
                case BinaryOperator.Caret:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.BitwiseOperators;
                    break;

                case BinaryOperator.Minus:
                case BinaryOperator.Plus:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.AdditiveOperators;
                    break;

                case BinaryOperator.Asterisk:
                case BinaryOperator.Slash:
                case BinaryOperator.Percent:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.MultiplicativeOperators;
                    break;

                case BinaryOperator.GreaterThanGreaterThan:
                case BinaryOperator.LessThanLessThan:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.ShiftOperators;
                    break;

                case BinaryOperator.QuestionQuestion:
                    writeSpace = _writer.Configuration.Spaces.AroundOperators.NullCoalescingOperator;
                    break;

                default: throw ThrowHelper.InvalidEnumValue(node.Operator);
            }

            if (writeSpace)
                _writer.WriteSpace();

            if (_writer.Configuration.Other.AlignMultiLineConstructs.ChainedBinaryExpressions)
                _writer.SetAlignmentBreak(true);

            if (wrap && _writer.Configuration.LineBreaksAndWrapping.LineWrapping.PreferWrapBeforeOperatorInBinaryExpression)
                _writer.Break(true);

            switch (node.Operator)
            {
                case BinaryOperator.Ampersand: _writer.WriteOperator(PrinterOperator.Ampersand); break;
                case BinaryOperator.AmpersandAmpersand: _writer.WriteOperator(PrinterOperator.AmpersandAmpersand); break;
                case BinaryOperator.AmpersandEquals: _writer.WriteOperator(PrinterOperator.AmpersandEquals); break;
                case BinaryOperator.AsKeyword: _writer.WriteKeyword(PrinterKeyword.As); break;
                case BinaryOperator.Asterisk: _writer.WriteOperator(PrinterOperator.Asterisk); break;
                case BinaryOperator.AsteriskEquals: _writer.WriteOperator(PrinterOperator.AsteriskEquals); break;
                case BinaryOperator.Bar: _writer.WriteOperator(PrinterOperator.Bar); break;
//.........這裏部分代碼省略.........
開發者ID:modulexcite,項目名稱:CSharpSyntax,代碼行數:101,代碼來源:SyntaxPrinter.cs


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