Exemplo n.º 1
0
        /// <summary>
        /// 访问 Concat 方法
        /// </summary>
        /// <param name="m">方法表达式</param>
        protected override Expression VisitConcat(MethodCallExpression m)
        {
            IList <Expression> expressions = null;

            if (m.Arguments.Count > 1)
            {
                expressions = m.Arguments;
            }
            else if (m.Arguments.Count == 1 && m.Arguments[0].NodeType == ExpressionType.NewArrayInit)
            {
                expressions = (m.Arguments[0] as NewArrayExpression).Expressions;
            }

            if (expressions == null)
            {
                _visitor.Visit(m.Arguments[0]);
            }
            else
            {
                _builder.Append("(");
                for (int i = 0; i < expressions.Count; i++)
                {
                    _visitor.VisitWithoutStack(_ => this.VisitToStringImpl(expressions[i]));
                    if (i < expressions.Count - 1)
                    {
                        _builder.Append(" || ");
                    }
                }
                _builder.Append(")");
            }
            return(m);
        }