Пример #1
0
        protected override void Visit([NotNull] InjectChunk chunk)
        {
            Writer.WriteLine(_activateAttribute);

            // 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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 public override void GenerateChunk(Span target, ChunkGeneratorContext context)
 {
     var injectChunk = new InjectChunk(TypeName, PropertyName);
     context.ChunkTreeBuilder.AddChunk(injectChunk, target);
 }
Пример #4
0
 protected override void Visit(InjectChunk chunk)
 {
 }
Пример #5
0
 protected override void Visit(InjectChunk chunk)
 {
 }
Пример #6
0
 protected abstract void Visit(InjectChunk chunk);
Пример #7
0
        public override void GenerateCode(Span target, CodeGeneratorContext context)
        {
            var injectChunk = new InjectChunk(TypeName, PropertyName);

            context.CodeTreeBuilder.AddChunk(injectChunk, target);
        }