Пример #1
0
 static void Main(string[] args)
 {
     //object[] o1 = new object[] { 1 };
     //object[] o2 = new object[] { 1 };
     //Tuple<string, object[]> t1 = new Tuple<string, object[]>("a", new object[] { new int[] { 1 } });
     //Tuple<string, object[]> t2 = new Tuple<string, object[]>("a", new object[] { new int[] { 1 } });
     //Console.WriteLine(o1 == o2);
     //Console.WriteLine(t1 == t2);
     //GenericFactory factory = new GenericFactory();
     //object o = factory.CreateObject("System.String", false, 'u');
     TagBuilder tag = new TagBuilder();
     tag.Indentation = 2;
     tag.prettyPrint = true;
     var script =
         tag.StartTag("parent")
             .AddAttribute("parentproperty1", "true")
             .AddAttribute("parentproperty2", "5")
                 .StartTag("child1")
                 .AddAttribute("childproperty1", "c")
                 .AddContent("childbody")
                 .EndTag()
                 .StartTag("child2")
                 .AddAttribute("childproperty2", "c")
                 .AddContent("childbody")
                 .EndTag()
             .EndTag()
             .StartTag("script")
             .AddContent("$.scriptbody();")
             .EndTag()
             .ToString();
     Console.WriteLine(script);
     Console.ReadKey();
 }
Пример #2
0
        public void Returns_properly_indented_child_tag_with_contents()
        {
            TagBuilder tag = new TagBuilder();
            tag.IsIndented = true;
            var result = tag.StartTag("parent").StartTag("child").AddContent("content").EndTag().EndTag().ToString();

            Assert.AreEqual("<parent>    <child>        content    </child></parent>", result);
        }
Пример #3
0
        public void Returns_properly_indented_child()
        {
            TagBuilder tag = new TagBuilder();
            tag.IsIndented = true;
            var result = tag.StartTag("parent").AddContent("normal_child").EndTag().ToString();

            Assert.AreEqual("<parent>    normal_child</parent>", result);
        }
Пример #4
0
        public void Prettyprint_test()
        {
            TagBuilder tag = new TagBuilder();
            tag.prettyPrint = true;
            var result = tag.StartTag("parent").StartTag("child").AddContent("content").EndTag().EndTag().ToString();

            Assert.AreEqual("<parent>\n    <child>\n        content\n    </child>\n</parent>\n", result);
        }
Пример #5
0
        public void Returns_properties_within_same_line()
        {
            // no indent
            TagBuilder tag = new TagBuilder();
            tag.IsIndented = true;
            var result = tag.StartTag("parent").AddAttribute("attr", "val").AddContent("content").EndTag().ToString();

            Assert.AreEqual("<parent attr='val'>    content</parent>", result);
        }
Пример #6
0
        public void Properly_handles_indentation_depth()
        {
            TagBuilder tag = new TagBuilder();
            tag.IsIndented = true;
            tag.Indentation = 2; // hipsters'
            var result = tag.StartTag("parent").AddContent("content").EndTag().ToString();

            Assert.AreEqual("<parent>  content</parent>", result);
        }
Пример #7
0
 public TagBuilder(string TagName, TagBuilder Parent)
     : this()
 {
     this.tagName = TagName;
     this.parent = Parent;
     this._level = Parent._level + 1;
     this.prettyPrint = this.parent.prettyPrint;
     this.Indentation = this.parent.Indentation;
     this.IsIndented = this.parent.IsIndented;
 }
Пример #8
0
 public TagBuilder StartTag(string TagName)
 {
     TagBuilder tag = new TagBuilder(TagName, this);
     return tag;
 }