private string ConvertToString(Expression e)
        {
            var sw      = new StringWriter();
            var emitter = new CSharpExpressionEmitter(sw);

            emitter.Visit(e);
            return(sw.ToString());
        }
예제 #2
0
        public static string EmitInstantiation(ExpressionSerializationManager manager,
                                               TextWriter output,
                                               object component)
        {
            var exp   = manager.Serialize(component);
            var cache = new StringWriter();

            var emit = new CSharpExpressionEmitter(cache);

            emit.Visit(exp);

            foreach (var m in emit.decls)
            {
                output.WriteLine(m);
            }

            output.WriteLine(cache);

            // First element of block should be name
            var block = (BlockExpression)exp;
            var name  = (NameExpression)((BinaryExpression)block.Expressions[0]).Left;

            return(name.Name);
        }