public override RazorCSharpDocument WriteDocument(RazorCodeDocument codeDocument, DocumentIntermediateNode node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } var wr = new CodeWriter(); var ctx = new DefaultCodeRenderingContext(wr, node.Target.CreateNodeWriter(), codeDocument, node, node.Options); var visitor = new Visitor(node.Target, ctx); ctx.Visitor = visitor; visitor.VisitDocument(node); return(new ReactCSharpDocument(wr.GenerateCode(), new RazorDiagnostic[0], node.Options)); }
public static CodeRenderingContext CreateDesignTime( string newLineString = null, string suppressUniqueIds = "test", RazorSourceDocument source = null, IntermediateNodeWriter nodeWriter = null) { var codeWriter = new CodeWriter(); var documentNode = new DocumentIntermediateNode(); var options = RazorCodeGenerationOptions.CreateDesignTimeDefault(); if (source == null) { source = TestRazorSourceDocument.Create(); } var codeDocument = RazorCodeDocument.Create(source); if (newLineString != null) { codeDocument.Items[CodeRenderingContext.NewLineString] = newLineString; } if (suppressUniqueIds != null) { codeDocument.Items[CodeRenderingContext.SuppressUniqueIds] = suppressUniqueIds; } if (nodeWriter == null) { nodeWriter = new DesignTimeNodeWriter(); } var context = new DefaultCodeRenderingContext(codeWriter, nodeWriter, codeDocument, documentNode, options); context.Visitor = new RenderChildrenVisitor(context); return(context); }
public Visitor(CodeTarget target, DefaultCodeRenderingContext context) { _target = target; _context = context; }