Exemple #1
0
        /// <summary>
        /// Binds a LambdaToken to metadata.
        /// </summary>
        /// <param name="lambdaToken">Token to bind.</param>
        /// <param name="state">Object to hold the state of binding.</param>
        /// <returns>A metadata bound any or all node.</returns>
        internal LambdaNode BindLambdaToken(LambdaToken lambdaToken, BindingState state)
        {
            ExceptionUtils.CheckArgumentNotNull(lambdaToken, "LambdaToken");
            ExceptionUtils.CheckArgumentNotNull(state, "state");

            // Start by binding the parent token
            CollectionNode parent        = this.BindParentToken(lambdaToken.Parent);
            RangeVariable  rangeVariable = null;

            // Add the lambda variable to the stack
            if (lambdaToken.Parameter != null)
            {
                rangeVariable = NodeFactory.CreateParameterNode(lambdaToken.Parameter, parent);
                state.RangeVariables.Push(rangeVariable);
            }

            // Bind the expression
            SingleValueNode expression = this.BindExpressionToken(lambdaToken.Expression);

            // Create the node
            LambdaNode lambdaNode = NodeFactory.CreateLambdaNode(state, parent, expression, rangeVariable, lambdaToken.Kind);

            // Remove the lambda variable as it is now out of scope
            if (rangeVariable != null)
            {
                state.RangeVariables.Pop();
            }

            return(lambdaNode);
        }
Exemple #2
0
        /// <summary>
        /// Binds a LambdaToken to metadata.
        /// </summary>
        /// <param name="lambdaToken">Token to bind.</param>
        /// <param name="state">Object to hold the state of binding.</param>
        /// <returns>A metadata bound any or all node.</returns>
        internal LambdaNode BindLambdaToken(LambdaToken lambdaToken, BindingState state)
        {
            ExceptionUtils.CheckArgumentNotNull(lambdaToken, "LambdaToken");
            ExceptionUtils.CheckArgumentNotNull(state, "state");

            // Start by binding the parent token
            CollectionNode parent = this.BindParentToken(lambdaToken.Parent);
            RangeVariable rangeVariable = null;

            // Add the lambda variable to the stack
            if (lambdaToken.Parameter != null)
            {
                rangeVariable = NodeFactory.CreateParameterNode(lambdaToken.Parameter, parent);
                state.RangeVariables.Push(rangeVariable);
            }

            // Bind the expression
            SingleValueNode expression = this.BindExpressionToken(lambdaToken.Expression);
            
            // Create the node
            LambdaNode lambdaNode = NodeFactory.CreateLambdaNode(state, parent, expression, rangeVariable, lambdaToken.Kind);

            // Remove the lambda variable as it is now out of scope
            if (rangeVariable != null)
            {
                state.RangeVariables.Pop();
            }

            return lambdaNode;
        }
        /// <summary>
        /// Binds a LambdaToken.
        /// </summary>
        /// <param name="lambdaToken">The LambdaToken to bind.</param>
        /// <returns>A bound Any or All node.</returns>
        protected virtual QueryNode BindAnyAll(LambdaToken lambdaToken)
        {
            ExceptionUtils.CheckArgumentNotNull(lambdaToken, "LambdaToken");

            LambdaBinder binder = new LambdaBinder(this.Bind);

            return(binder.BindLambdaToken(lambdaToken, this.BindingState));
        }
        public void ShoulHandleNullArgument()
        {
            var call   = new CallToken(null);
            var group  = new GroupToken(null);
            var lambda = new LambdaToken(null);
            var obj    = new ObjectToken(null);
            var array  = new ArrayToken(null);

            Assert.NotNull(call.Args);
            Assert.NotNull(group.Tokens);
            Assert.NotNull(lambda.Parameters);
            Assert.NotNull(obj.Members);
            Assert.NotNull(array.Items);
        }
Exemple #5
0
 /// <summary>
 /// Visits a LambdaToken
 /// </summary>
 /// <param name="tokenIn">The LambdaToken to visit</param>
 /// <returns>A LambdaNode bound to this LambdaToken</returns>
 public virtual T Visit(LambdaToken tokenIn)
 {
     throw new NotImplementedException();
 }
 public Expression Visit(LambdaToken tokenIn)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
        /// <summary>
        /// Binds a LambdaToken.
        /// </summary>
        /// <param name="lambdaToken">The LambdaToken to bind.</param>
        /// <returns>A bound Any or All node.</returns>
        protected virtual QueryNode BindAnyAll(LambdaToken lambdaToken)
        {
            ExceptionUtils.CheckArgumentNotNull(lambdaToken, "LambdaToken");

            LambdaBinder binder = new LambdaBinder(this.Bind);
            return binder.BindLambdaToken(lambdaToken, this.BindingState);
        }
 public bool Visit(LambdaToken tokenIn)
 {
     throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "QueryToken of type '{0}' is not supported.", tokenIn.Kind));
 }