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);
        }
Exemple #2
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);
        }
Exemple #3
0
        protected override void Visit(ModelChunk chunk)
        {
            var csharpVisitor = new CSharpCodeVisitor(Writer, Context);

            Writer.Write(chunk.BaseType).Write("<");
            csharpVisitor.CreateExpressionCodeMapping(chunk.ModelType, chunk);
            Writer.Write(">");
        }