Beispiel #1
0
        private void VisitViewdata(SpecialNodeInspector inspector)
        {
            AttributeNode attr     = inspector.TakeAttribute("default");
            Snippets      snippets = null;

            if (attr != null)
            {
                snippets = this.AsTextOrientedCode(attr);
            }
            AttributeNode node2 = inspector.TakeAttribute("model");

            if (node2 != null)
            {
                TypeInspector      inspector2 = new TypeInspector(this.AsCode(node2));
                ViewDataModelChunk chunk      = new ViewDataModelChunk {
                    TModel      = inspector2.Type,
                    TModelAlias = inspector2.Name
                };
                this.AddUnordered(chunk);
            }
            foreach (AttributeNode node3 in inspector.Attributes)
            {
                TypeInspector inspector3 = new TypeInspector(this.AsCode(node3));
                ViewDataChunk chunk2     = new ViewDataChunk {
                    Type     = inspector3.Type,
                    Name     = inspector3.Name ?? node3.Name,
                    Key      = node3.Name,
                    Default  = snippets,
                    Position = this.Locate(node3)
                };
                this.AddUnordered(chunk2);
            }
        }
Beispiel #2
0
 protected override void Visit(ViewDataModelChunk chunk)
 {
     if (!Snippets.IsNullOrEmpty(TModel) && TModel != chunk.TModel)
     {
         throw new CompilerException(string.Format("Only one viewdata model can be declared. {0} != {1}", TModel,
                                                   chunk.TModel));
     }
     TModel = chunk.TModel;
 }
 protected override void Visit(ViewDataModelChunk chunk)
 {
     if (this._encounteredTModel && !string.Equals((string)this.TModel, (string)chunk.TModel, StringComparison.Ordinal))
     {
         throw new CompilerException(string.Format("Only one viewdata model can be declared. {0} != {1}", this.TModel, chunk.TModel));
     }
     this.TModel             = chunk.TModel;
     this._encounteredTModel = true;
 }
 protected override void Visit(ViewDataModelChunk chunk)
 {
     if (!Snippets.IsNullOrEmpty(chunk.TModelAlias))
     {
         this._source.WriteCode(chunk.TModel).Write(" ").WriteCode(chunk.TModelAlias).WriteLine();
         this.CodeIndent(chunk).WriteLine("{get {return ViewData.Model;}}");
         this.CodeDefault();
     }
 }
Beispiel #5
0
 protected override void Visit(ViewDataModelChunk chunk)
 {
     if (_encounteredTModel && !string.Equals(TModel, chunk.TModel, StringComparison.Ordinal))
     {
         throw new CompilerException(string.Format("Only one viewdata model can be declared. {0} != {1}", TModel,
                                                   chunk.TModel));
     }
     TModel = chunk.TModel;
     _encounteredTModel = true;
 }
 protected override void Visit(ViewDataModelChunk chunk)
 {
     if (!Snippets.IsNullOrEmpty(chunk.TModelAlias))
     {
         this._source.Write("Public ReadOnly Property ").WriteCode(chunk.TModelAlias).Write("() As ").WriteCode(chunk.TModel).WriteLine().AddIndent();
         this._source.WriteLine("Get").AddIndent();
         this._source.WriteLine("Return ViewData.Model");
         this._source.RemoveIndent().WriteLine("End Get");
         this._source.RemoveIndent().WriteLine("End Property");
         this.CodeDefault();
     }
 }
Beispiel #7
0
        protected override void Visit(ViewDataModelChunk chunk)
        {
            if (Snippets.IsNullOrEmpty(chunk.TModelAlias))
                return;

            _source
                .WriteCode(chunk.TModel)
                .Write(" ")
                .WriteCode(chunk.TModelAlias)
                .WriteLine();
            CodeIndent(chunk).WriteLine("{get {return ViewData.Model;}}");
            CodeDefault();
        }
 protected abstract void Visit(ViewDataModelChunk chunk);
Beispiel #9
0
 protected override void Visit(ViewDataModelChunk chunk)
 {
     //no-op
 }
Beispiel #10
0
 protected override void Visit(ViewDataModelChunk chunk)
 {
 }
 protected abstract void Visit(ViewDataModelChunk chunk);
        protected override void Visit(ViewDataModelChunk chunk)
        {
            if (Snippets.IsNullOrEmpty(chunk.TModelAlias))
                return;

            _source
                .Write("Public ReadOnly Property ")
                .WriteCode(chunk.TModelAlias)
                .Write("() As ")
                .WriteCode(chunk.TModel)
                .WriteLine().AddIndent();
            _source.WriteLine("Get").AddIndent();
            _source.WriteLine("Return ViewData.Model");
            _source.RemoveIndent().WriteLine("End Get");
            _source.RemoveIndent().WriteLine("End Property");
            CodeDefault();
        }