Ejemplo n.º 1
0
        public void TestPartial2()
        {
                        LineInfo line = new LineInfo(1, string.Empty);
            line.Set("%input{ value=\"http://\"+domain+\"/voicemail/listen/\" + item.Id }", 0, 0);

            TagNode tagNode = new TagNode(null);
            NodeList nodes = new NodeList();
            AttributeNode node = new AttributeNode(tagNode);
            nodes.Add(node);
            nodes.Add(tagNode);

            int offset = 6;
            AttributeNode myNode = (AttributeNode)node.Parse(nodes, tagNode, line, ref offset);

            bool inStr = true;
            string res = myNode.ToCode(ref inStr, false);

            Assert.Equal("\"this\"+testCase.Id+\"id\"", myNode.GetAttribute("value").Value);
            Assert.Equal("value=\"\"\"); sb.Append(\"this\"+testCase.Id+\"id\"); sb.Append(@\"\"\"", res);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            LineInfo line = new LineInfo(1, string.Empty);
            line.Set("%input{ type=\"checkbox\", value=testCase.Id, name=\"case\", class=lastCat.Replace(' ', '-')}", 0,
                     0);

            TagNode tagNode = new TagNode(null);
            NodeList nodes = new NodeList();
            AttributeNode node = new AttributeNode(tagNode);
            nodes.Add(node);
            nodes.Add(tagNode);

            int offset = 6;
            AttributeNode myNode  = (AttributeNode)node.Parse(nodes, tagNode, line, ref offset);
            bool t = false;
            string temp = myNode.ToCode(ref t, false);
            Assert.Equal("\"checkbox\"", myNode.GetAttribute("type").Value);
            Assert.Equal("testCase.Id", myNode.GetAttribute("value").Value);
            Assert.Equal("\"case\"", myNode.GetAttribute("name").Value);
            Assert.Equal("lastCat.Replace(' ', '-')", myNode.GetAttribute("class").Value);
        }
Ejemplo n.º 3
0
        public void TestPartial3()
        {
                        LineInfo line = new LineInfo(1, string.Empty);
            line.Set("%a{href=\"/settings/divert/remove/\", title=Language[\"RemoveDivert\"] }", 0, 0);

            TagNode tagNode = new TagNode(null);
            NodeList nodes = new NodeList();
            AttributeNode node = new AttributeNode(tagNode);
            nodes.Add(node);
            nodes.Add(tagNode);

            int offset = 2;
            AttributeNode myNode = (AttributeNode)node.Parse(nodes, tagNode, line, ref offset);

            bool inStr = true;
            string res = myNode.ToCode(ref inStr, false);

            //Assert.Equal("\"this\"+testCase.Id+\"id\"", myNode.GetAttribute("value").Value);
            //Assert.Equal("value=\"\"\"); sb.Append(\"this\"+testCase.Id+\"id\"); sb.Append(@\"\"\"", res);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parse a file and convert into to our own template object code.
        /// </summary>
        /// <param name="reader">A <see cref="TextReader"/> containing our template</param>
        /// <exception cref="CodeGeneratorException">If something is incorrect in the template.</exception>
        public void Parse(TextReader reader)
        {
            _lineNo = -1;
            _reader = reader;
            _mother = new LineInfo(-1, string.Empty);
            _prevLine = null;
            _currentLine = null;

            PreParse(reader);

            NodeList prototypes = new NodeList();
            prototypes.Add(new AttributeNode(null));
            prototypes.Add(new TagNode(null));
            prototypes.Add(new IdNode(null));
            prototypes.Add(new SilentCodeNode(null));
            prototypes.Add(new ClassNode(null));
            prototypes.Add(new DisplayCodeNode(null));
            prototypes.Add(new DocTypeTag(null, null));
			prototypes.Add(new PartialNode(null));
            TextNode textNode = new TextNode(null, "prototype");
            _parentNode = new TextNode(null, string.Empty);

            foreach (LineInfo info in _mother.Children)
                ParseNode(info, prototypes, _parentNode, textNode);
        }