Exemple #1
0
        /// <summary>
        /// Uses the precedence operator only if needed. i.e. '(' operations ')'.
        /// <para> - Writes '(' immediately, and returns a disposable that writes the ending ')'.</para>
        /// <para> - Pushes the operation into the stack, and pops it when disposed.</para>
        /// </summary>
        /// <param name="node">The node representing the operation that is going to be rendered inside the using block.</param>
        /// <returns>Disposable that renders the ending ')' of the precedence operator.</returns>
        public IDisposable Operation(Expression node)
        {
            var op = JsOperationHelper.GetJsOperator(node.NodeType, node.Type);

            if (op == JavascriptOperationTypes.NoOp)
            {
                return(null);
            }

            return(new Precedence(this.result, this.operandTypes, op));
        }
        private bool CurrentHasPrecedence()
        {
            var cnt = this.operandTypes.Count;

            if (cnt < 2)
            {
                return(true);
            }

            var current = this.operandTypes[cnt - 1];
            var parent  = this.operandTypes[cnt - 2];

            return(JsOperationHelper.CurrentHasPrecedence(current, parent));
        }
Exemple #3
0
 /// <summary>
 /// Writes the operator that corresponds to the given expression type.
 /// </summary>
 /// <param name="expressionType">Expression type representing the operator to render..</param>
 /// <returns>The <see cref="JavascriptWriter"/>, allowing a fluent style.</returns>
 public JavascriptWriter WriteOperator(ExpressionType expressionType, Type type)
 {
     JsOperationHelper.WriteOperator(this.result, expressionType, type);
     return(this);
 }