public Visit ( Nustache.Core.Block block ) : void | ||
block | Nustache.Core.Block | |
Результат | void |
public void Visit(Block block) { parts.Add(context.GetInnerExpressions(block.Name, value => { context.Push(block, value); if (typeof(Lambda <string>).BaseType.IsAssignableFrom(value.Type)) { return (Expression.Call( Expression.Call(value, value.Type.GetMethod("Invoke"), Expression.Constant(block.InnerSource())), typeof(object).GetMethod("ToString"))); } var visitor = new CompilePartVisitor(context); visitor.Visit((Section)block); var expression = CompoundExpression.NullCheck(value, nullValue: "", returnIfNotNull: visitor.Result()); context.Pop(); return(expression); })); }
public void Visit(Block block) { parts.Add(context.GetInnerExpressions(block.Name, value => { context.Push(block, value); if (typeof(Lambda<string>).BaseType.IsAssignableFrom(value.Type)) { return Expression.Call( Expression.Call(value, value.Type.GetMethod("Invoke"), Expression.Constant(block.InnerSource())), typeof(object).GetMethod("ToString")); } var visitor = new CompilePartVisitor(context); visitor.Visit((Section)block); var expression = CompoundExpression.NullCheck(value, nullValue: "", returnIfNotNull: visitor.Result()); context.Pop(); return expression; })); }
public static Expression Compile(this Template template, CompileContext context) { var visitor = new CompilePartVisitor(context); visitor.Visit(template); return(visitor.Result()); }
public void Visit(InvertedBlock invertedBlock) { parts.Add(context.GetInnerExpressions(invertedBlock.Name, value => { // the logic here is really confusing, but since GetInnerExpressions does // the truthiness check, it is basically the same as Block.Compile var visitor = new CompilePartVisitor(context); visitor.Visit((Section)invertedBlock); var expression = visitor.Result(); return(expression); }, invert: true)); }
public void Visit(InvertedBlock invertedBlock) { parts.Add(context.GetInnerExpressions(invertedBlock.Name, value => { // the logic here is really confusing, but since GetInnerExpressions does // the truthiness check, it is basically the same as Block.Compile var visitor = new CompilePartVisitor(context); visitor.Visit((Section)invertedBlock); var expression = visitor.Result(); return expression; }, invert: true)); }