protected override void Visit(InjectChunk chunk) { if (chunk == null) { throw new ArgumentNullException(nameof(chunk)); } Writer.WriteLine(_injectAttribute); // Some of the chunks that we visit are either InjectDescriptors that are added by default or // are chunks from _ViewStart files and are not associated with any Spans. Invoking // CreateExpressionMapping to produce line mappings on these chunks would fail. We'll skip // generating code mappings for these chunks. This makes sense since the chunks do not map // to any code in the current view. if (Context.Host.DesignTimeMode && chunk.Association != null) { Writer.WriteLine("public"); var code = string.IsNullOrEmpty(chunk.MemberName) ? chunk.TypeName : chunk.TypeName + " " + chunk.MemberName; var csharpVisitor = new CSharpCodeVisitor(Writer, Context); csharpVisitor.CreateExpressionCodeMapping(code, chunk); Writer.WriteLine("{ get; private set; }"); } else { Writer.Write("public ") .Write(chunk.TypeName) .Write(" ") .Write(chunk.MemberName) .WriteLine(" { get; private set; }"); } InjectChunks.Add(chunk); }
protected abstract void Visit(InjectChunk chunk);
public override void GenerateChunk(Span target, ChunkGeneratorContext context) { var injectChunk = new InjectChunk(TypeName, PropertyName); context.ChunkTreeBuilder.AddChunk(injectChunk, target); }
protected override void Visit(InjectChunk chunk) { }