Esempio n. 1
0
        private void VisitViewdata(SpecialNodeInspector inspector)
        {
            var      defaultAttr  = inspector.TakeAttribute("default");
            Snippets defaultValue = null;

            if (defaultAttr != null)
            {
                defaultValue = AsCode(defaultAttr);
            }

            var modelAttr = inspector.TakeAttribute("model");

            if (modelAttr != null)
            {
                var typeInspector = new TypeInspector(AsCode(modelAttr));
                AddUnordered(new ViewDataModelChunk {
                    TModel = typeInspector.Type, TModelAlias = typeInspector.Name
                });
            }

            foreach (var attr in inspector.Attributes)
            {
                var typeInspector = new TypeInspector(AsCode(attr));
                AddUnordered(new ViewDataChunk
                {
                    Type     = typeInspector.Type,
                    Name     = typeInspector.Name ?? attr.Name,
                    Key      = attr.Name,
                    Default  = defaultValue,
                    Position = Locate(attr)
                });
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
 public void SimpleFields()
 {
     var result = new TypeInspector("string");
     Assert.AreEqual("string", (string)result.Type);
     Assert.IsNull(result.Name);
 }
Esempio n. 4
0
 public void GenericWithSpacesButNoName()
 {
     var result = new TypeInspector("IList<something, int>");
     Assert.AreEqual("IList<something, int>", (string)result.Type);
     Assert.IsNull(result.Name);
 }
Esempio n. 5
0
 public void GenericsWithName()
 {
     var result = new TypeInspector("IList<something>\r\n\tSomethingList");
     Assert.AreEqual("IList<something>", (string)result.Type);
     Assert.AreEqual("SomethingList", (string)result.Name);
 }
Esempio n. 6
0
 public void Generics()
 {
     var result = new TypeInspector("IList<something>");
     Assert.AreEqual("IList<something>", (string)result.Type);
     Assert.IsNull(result.Name);
 }
Esempio n. 7
0
        private void VisitViewdata(SpecialNodeInspector inspector)
        {
            var defaultAttr = inspector.TakeAttribute("default");
            Snippets defaultValue = null;
            if (defaultAttr != null)
                defaultValue = AsCode(defaultAttr);

            var modelAttr = inspector.TakeAttribute("model");
            if (modelAttr != null)
            {
                var typeInspector = new TypeInspector(AsCode(modelAttr));
                AddUnordered(new ViewDataModelChunk { TModel = typeInspector.Type, TModelAlias = typeInspector.Name });
            }

            foreach (var attr in inspector.Attributes)
            {
                var typeInspector = new TypeInspector(AsCode(attr));
                AddUnordered(new ViewDataChunk
                                 {
                                     Type = typeInspector.Type,
                                     Name = typeInspector.Name ?? attr.Name,
                                     Key = attr.Name,
                                     Default = defaultValue,
                                     Position = Locate(attr)
                                 });
            }
        }