public CSharpHelperVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor, [NotNull] CSharpCodeWriter writer, [NotNull] CodeBuilderContext context) : base(writer, context) { _csharpCodeVisitor = csharpCodeVisitor; }
private void RenderTagOutput(string tagOutputMethodName) { CSharpCodeVisitor.RenderPreWriteStart(_writer, _context); _writer.Write(ExecutionContextVariableName) .Write(".") .Write(_tagHelperContext.ExecutionContextOutputPropertyName) .Write(".") .WriteMethodInvocation(tagOutputMethodName, endLine: false) .WriteEndMethodInvocation(); }
private void RenderTagOutput(string tagOutputMethodName) { // Rendering output is a runtime feature. if (_designTimeMode) { return; } CSharpCodeVisitor.RenderPreWriteStart(_writer, _context); _writer.Write(ExecutionContextVariableName) .Write(".") .Write(_tagHelperContext.ExecutionContextOutputPropertyName) .Write(".") .WriteMethodInvocation(tagOutputMethodName, endLine: false) .WriteEndMethodInvocation(); }
public CSharpHelperVisitor(CSharpCodeWriter writer, CodeGeneratorContext context) : base(writer, context) { _codeVisitor = new CSharpCodeVisitor(writer, context); }
private void RenderTagHelperContent() { // Rendering output is a runtime feature. if (_designTimeMode) { return; } _writer.Write("if (") .Write(ExecutionContextVariableName) .Write(".") .Write(_tagHelperContext.ExecutionContextOutputPropertyName) .Write(".") .Write(_tagHelperContext.OutputContentSetPropertyName) .WriteLine(")"); // At this point in the codegen, TagHelperOutput.Content is set. We need to use this to render the Content // instead of executing the child content using (_writer.BuildScope()) { RenderTagOutput(_tagHelperContext.OutputGenerateContentMethodName); } _writer.Write("else if (") .Write(ExecutionContextVariableName) .Write(".") .Write(_tagHelperContext.ExecutionContextChildContentRetrievedPropertyName) .WriteLine(")"); // Render the body of the else if statement, at this point in the codegen the GetChildContentAsync method // was invoked but the TagHelperOutput's Content was not set. Call into GetChildContentAsync to retrieve // the cached value of the content so we don't execute the child content twice. using (_writer.BuildScope()) { CSharpCodeVisitor.RenderPreWriteStart(_writer, _context); _writer.WriteInstanceMethodInvocation(ExecutionContextVariableName, _tagHelperContext.ExecutionContextGetChildContentAsyncMethodName, endLine: false); _writer.Write(".Result") .WriteEndMethodInvocation(); } _writer.WriteLine("else"); // Render the body of the else statement, at this point in the codegen the GetChildContentAsync method // was not invoked and the TagHelperOutput's Content was not set. Call into ExecuteChildContentAsync to // to execute and render child content. using (_writer.BuildScope()) { if (!string.IsNullOrEmpty(_context.TargetWriterName)) { _writer.WriteMethodInvocation( _tagHelperContext.StartWritingScopeMethodName, _context.TargetWriterName); } _writer.WriteInstanceMethodInvocation( ExecutionContextVariableName, _tagHelperContext.ExecutionContextExecuteChildContentAsyncMethodName, endLine: false); _writer.WriteLine(".Wait();"); if (!string.IsNullOrEmpty(_context.TargetWriterName)) { _writer.WriteMethodInvocation(_tagHelperContext.EndWritingScopeMethodName); } } }
public CSharpTypeMemberVisitor(CSharpCodeWriter writer, CodeGeneratorContext context) : base(writer, context) { _csharpCodeVisitor = new CSharpCodeVisitor(writer, context); }