protected XElement ParseSdt(ITagProcessor parentProcessor, XElement sdtElement) { ITagParser parser = null; switch (this.GetTagName(sdtElement).ToLower()) { case "htmlcontent": parser = new HtmlContentParser(); break; case "text": parser = new TextParser(); break; case "table": parser = new TableParser(); break; case "repeater": parser = new RepeaterParser(); break; case "if": parser = new IfParser(); break; } return parser != null ? parser.Parse(parentProcessor, sdtElement) : sdtElement; }
protected XElement ParseSdt(ITagProcessor parentProcessor, XElement sdtElement) { ITagParser parser = null; switch (this.GetTagName(sdtElement).ToLower()) { case "htmlcontent": parser = new HtmlContentParser(); break; case "text": parser = new TextParser(); break; case "table": parser = new TableParser(); break; case "repeater": parser = new RepeaterParser(); break; case "if": parser = new IfParser(); break; } return(parser != null?parser.Parse(parentProcessor, sdtElement) : sdtElement); }
public void TestParseVariousOrderTag() { var processorMock = new TagProcessorMock<TableProcessor>(); var parser = new TableParser(); var root = new XElement(this.documentRoot); var paragraph = root.Element(WordMl.ParagraphName); //var itemsElement = TraverseUtils.TagElement(root, "Items"); //itemsElement.AddBeforeSelf(paragraph); //var dynamicRowElement = TraverseUtils.TagElement(root, "DynamicRow"); //dynamicRowElement.AddBeforeSelf(paragraph); //var contentElement = TraverseUtils.TagElement(root, "Content"); //contentElement.AddBeforeSelf(paragraph); //var endContentElement = TraverseUtils.TagElement(root, "EndContent"); //endContentElement.AddBeforeSelf(paragraph); var tableElement = root.Element(WordMl.TableName); Assert.IsNotNull(tableElement); tableElement.AddBeforeSelf(paragraph); var endTableElement = TraverseUtils.TagElement(root, "EndTable"); endTableElement.AddBeforeSelf(paragraph); var startElement = TraverseUtils.TagElement(root, "Table"); parser.Parse(processorMock, startElement); var processor = processorMock.InnerProcessor; var tag = processor.TableTag; Assert.AreEqual(4, tag.DynamicRow); Assert.AreEqual("//test/certificates", tag.ItemsSource); Assert.AreEqual(tableElement, tag.Table); this.CheckTagElements(tag); // itemsElement.Remove(); //endTableElement.AddBeforeSelf(itemsElement); parser.Parse(processorMock, startElement); processor = processorMock.InnerProcessor; tag = processor.TableTag; Assert.AreEqual(4, tag.DynamicRow); Assert.AreEqual("//test/certificates", tag.ItemsSource); Assert.AreEqual(tableElement, tag.Table); this.CheckTagElements(tag); //dynamicRowElement.Remove(); //endTableElement.AddBeforeSelf(dynamicRowElement); parser.Parse(processorMock, startElement); processor = processorMock.InnerProcessor; tag = processor.TableTag; Assert.AreEqual(4, tag.DynamicRow); Assert.AreEqual("//test/certificates", tag.ItemsSource); Assert.AreEqual(tableElement, tag.Table); this.CheckTagElements(tag); //contentElement.Remove(); tableElement.Remove(); //endContentElement.Remove(); //endTableElement.AddBeforeSelf(contentElement); endTableElement.AddBeforeSelf(tableElement); //endTableElement.AddBeforeSelf(endContentElement); parser.Parse(processorMock, startElement); processor = processorMock.InnerProcessor; tag = processor.TableTag; Assert.AreEqual(4, tag.DynamicRow); Assert.AreEqual("//test/certificates", tag.ItemsSource); Assert.AreEqual(tableElement, tag.Table); this.CheckTagElements(tag); }
public void TestParseNedted() { var parser = new TableParser(); var rootProcessor = new RootProcessor(); var tableElement = this.nestedDocumentRoot.Element(WordMl.TableName); parser.Parse(rootProcessor, this.nestedDocumentRoot.Elements(WordMl.SdtName).First()); var tableProcessor = rootProcessor.Processors.First(); var tag = ((TableProcessor)tableProcessor).TableTag; Assert.AreEqual(4, tag.DynamicRow); Assert.AreEqual("//test/certificates", tag.TagTable.Value); Assert.AreEqual(tableElement, tag.Table); this.CheckTagElements(tag); Assert.AreEqual(2, tableProcessor.Processors.Count); Assert.IsTrue(tableProcessor.Processors.All(p => p is TextProcessor)); }
public void TestParseNullProcess() { var root = new XElement(this.documentRoot); var startElement = TraverseUtils.TagElement(root, "Table"); var parser = new TableParser(); parser.Parse(null, startElement); }
public void TestParseMissingEndTableTag() { var processorMock = new TagProcessorMock<TableProcessor>(); var parser = new TableParser(); var root = new XElement(this.documentRoot); TraverseUtils.TagElement(root, "EndTable").Remove(); var startElement = TraverseUtils.TagElement(root, "Table"); parser.Parse(processorMock, startElement); }