Exemplo n.º 1
0
        /// <summary>
        /// Generates System.CodeDom.CodeExpression from the given expression.
        /// </summary>
        /// <param name="expression">Expression from which System.CodeDom.CodeExpression is generated.</param>
        /// <returns>Generated System.CodeDom.CodeExpression.</returns>
        public virtual CodeExpression Visit(QueryCastExpression expression)
        {
            CodeExpression    argument = this.GenerateCode(expression.Source);
            CodeTypeReference type     = this.GetTypeReference(expression.TypeToOperateAgainst);

            return(argument.Cast(type));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Evaluates the specified expression.
        /// </summary>
        /// <param name="expression">The expression to evaluate.</param>
        /// <returns>Value of the expression.</returns>
        public QueryValue Visit(QueryCastExpression expression)
        {
            var source = this.Evaluate(expression.Source);
            var type   = expression.TypeToOperateAgainst;

            return(source.Cast(type));
        }
        /// <summary>
        /// Replaces the given expression.
        /// </summary>
        /// <param name="expression">Expression to replace.</param>
        /// <returns>Replaced expression.</returns>
        public virtual QueryExpression Visit(QueryCastExpression expression)
        {
            var source = this.ReplaceExpression(expression.Source);

            if (this.HasChanged(expression.Source, source))
            {
                return(source.Cast(expression.TypeToOperateAgainst));
            }

            return(expression);
        }
            /// <summary>
            /// Visits a QueryExpression tree whose root node is the QueryCastExpression.
            /// </summary>
            /// <param name="expression">The root node of the expression tree being visited.</param>
            /// <returns>Uri query string representing the expression.</returns>
            public override string Visit(QueryCastExpression expression)
            {
                string argument       = this.Convert(expression.Source);
                string edmTypeLiteral = this.GetEdmTypeName(expression.TypeToOperateAgainst);

                if (string.IsNullOrEmpty(argument))
                {
                    return(string.Format(CultureInfo.InvariantCulture, "cast('{0}')", edmTypeLiteral));
                }

                return(string.Format(CultureInfo.InvariantCulture, "cast({0}, '{1}')", argument, edmTypeLiteral));
            }
            /// <summary>
            /// Visits a QueryExpression tree whose root node is the QueryCastExpression.
            /// </summary>
            /// <param name="expression">The root node of the expression tree being visited.</param>
            /// <returns>Uri query string representing the expression.</returns>
            public override string Visit(QueryCastExpression expression)
            {
                string argument = this.Convert(expression.Source);
                string edmTypeLiteral = this.GetEdmTypeName(expression.TypeToOperateAgainst);
                if (string.IsNullOrEmpty(argument))
                {
                    return string.Format(CultureInfo.InvariantCulture, "cast('{0}')", edmTypeLiteral);
                }

                return string.Format(CultureInfo.InvariantCulture, "cast({0}, '{1}')", argument, edmTypeLiteral);
            }
Exemplo n.º 6
0
 /// <summary>
 /// Visits a QueryExpression tree whose root node is the QueryCastExpression.
 /// </summary>
 /// <param name="expression">The root node of the expression tree being visited.</param>
 /// <returns>Uri query string representing the expression.</returns>
 public virtual string Visit(QueryCastExpression expression)
 {
     throw new TaupoNotSupportedException("Not supported");
 }
        /// <summary>
        /// Resolves types for the specified expression.
        /// </summary>
        /// <param name="expression">The expression to resolve types for.</param>
        /// <returns>Expression with resolved types.</returns>
        public QueryExpression Visit(QueryCastExpression expression)
        {
            var source = this.ResolveTypes(expression.Source);

            return(source.Cast(expression.TypeToOperateAgainst));
        }