Пример #1
0
        /// <summary>
        /// 转换表达式
        /// </summary>
        public override void ConvertToExpression()
        {
            var blockparames = new List <ParameterExpression>(10);
            var inits        = new List <Expression>(10);

            foreach (var item in Model)
            {
                switch (item.PtType)
                {
                case PrintType.String:
                    MethodCallExpression print = PrintProvide.ExpressionPrint(Expression.Constant(StringConvert.Convert1(item.SourcePath)));
                    inits.Add(print);
                    break;

                case PrintType.Variable:
                    var(param, path) = SearchPath(item.SourcePath);
                    blockparames.Add(param);
                    inits.Add(path);
                    if (string.IsNullOrWhiteSpace(item.FilterName))
                    {
                        print = PrintProvide.ExpressionPrint(param);
                    }
                    else
                    {
                        var argsexpression = new List <Expression>(5);
                        foreach (var arg in item.Args)
                        {
                            if (arg.FdType == FieldType.SourcePath)
                            {
                                var(parame, init) = SearchPath(arg.FdValue);
                                blockparames.Add(parame);
                                inits.Add(init);
                                argsexpression.Add(parame);
                            }
                            else
                            {
                                var value = CreateConstExpression(arg.FdType, arg.FdValue);
                                argsexpression.Add(Expression.Convert(value, typeof(object)));
                            }
                        }
                        print = PrintProvide.ExpressionPrint(param, item.FilterName, argsexpression.ToArray());
                    }
                    inits.Add(print);
                    break;

                default:
                    break;
                }
            }
            MethodCallExpression printLine = PrintProvide.ExpressionPrintLine();

            inits.Add(printLine);
            NdExpression = Expression.Block(blockparames, inits);
        }
Пример #2
0
 /// <summary>
 /// 转为表达式
 /// </summary>
 public override void ConvertToExpression()
 {
     NdExpression = PrintProvide.ExpressionPrintLine(Expression.Constant(StringConvert.Convert1(CodeString)));
 }