public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, StartTagName); var startTag = startElement; if (string.IsNullOrEmpty(startTag.Value)) { throw new Exception(string.Format(MessageStrings.TagNotFoundOrEmpty, "If")); } var endTag = this.FindEndTag(startTag); var content = TraverseUtils.ElementsBetween(startTag, endTag).ToList(); var expression = startTag.GetExpression(); var ifTag = new IfTag { Conidition = expression, EndIf = endTag, IfContent = content, StartIf = startTag, }; var ifProcessor = new IfProcessor { Tag = ifTag }; if (content.Any()) { this.GoDeeper(ifProcessor, content.First(), endTag); } parentProcessor.AddProcessor(ifProcessor); return endTag; }
public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, StartTagName); var startTag = startElement; if (string.IsNullOrEmpty(startTag.Value)) { throw new Exception(string.Format(MessageStrings.TagNotFoundOrEmpty, "If")); } var endTag = this.FindEndTag(startTag); var content = TraverseUtils.ElementsBetween(startTag, endTag).ToList(); var expression = startTag.GetExpression(); var ifTag = new IfTag { Conidition = expression, EndIf = endTag, IfContent = content, StartIf = startTag, }; var ifProcessor = new IfProcessor { Tag = ifTag }; if (content.Any()) { this.GoDeeper(ifProcessor, content.First(), endTag); } parentProcessor.AddProcessor(ifProcessor); return(endTag); }
public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, TagName); var endRepeater = TryGetRequiredTag(startElement, EndTagName); var itemsSource = startElement.GetExpression(); if (string.IsNullOrEmpty(itemsSource)) { throw new Exception(MessageStrings.ItemsAreEmpty); } IEnumerable <XElement> elementsBetween = TraverseUtils.ElementsBetween(startElement, endRepeater).ToList(); var repeaterTag = new RepeaterTag { Source = itemsSource, StartRepeater = startElement, EndRepeater = endRepeater, MakeElementCallback = MakeElementCallback }; var repeaterProcessor = new RepeaterProcessor { RepeaterTag = repeaterTag, }; if (elementsBetween.Any()) { this.GoDeeper(repeaterProcessor, elementsBetween.First()); } parentProcessor.AddProcessor(repeaterProcessor); return(endRepeater); }
public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, "HtmlContent"); var tag = new HtmlContentTag() { Expression = startElement.Value, TagNode = startElement }; var processor = new HtmlContentProcessor() { HtmlTag = tag }; parentProcessor.AddProcessor(processor); return startElement; }
public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, "Text"); var tag = new TextTag { Expression = startElement.Value, TagNode = startElement }; var processor = new TextProcessor { TextTag = tag }; parentProcessor.AddProcessor(processor); return(startElement); }
/// <summary> /// Do parsing /// </summary> public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, "Table"); if (parentProcessor == null) { throw new ArgumentNullException(); } var endTableTag = this.TryGetRequiredTags(startElement, "EndTable").First(); var coreParser = new CoreTableParser(false); var tag = coreParser.Parse(startElement, endTableTag); var processor = new TableProcessor { TableTag = tag }; if (TraverseUtils.ElementsBetween(startElement, endTableTag).Any()) { this.GoDeeper(processor, TraverseUtils.ElementsBetween(startElement, endTableTag).First()); } parentProcessor.AddProcessor(processor); return endTableTag; }
/// <summary> /// Do parsing /// </summary> public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, "Table"); if (parentProcessor == null) { throw new ArgumentNullException(); } var endTableTag = this.TryGetRequiredTags(startElement, "EndTable").First(); var coreParser = new CoreTableParser(false); var tag = coreParser.Parse(startElement, endTableTag); var processor = new TableProcessor { TableTag = tag }; if (TraverseUtils.ElementsBetween(startElement, endTableTag).Any()) { this.GoDeeper(processor, TraverseUtils.ElementsBetween(startElement, endTableTag).First()); } parentProcessor.AddProcessor(processor); return(endTableTag); }
public override XElement Parse(ITagProcessor parentProcessor, XElement startElement) { this.ValidateStartTag(startElement, TagName); var endRepeater = TryGetRequiredTag(startElement, EndTagName); var itemsSource = startElement.GetExpression(); if (string.IsNullOrEmpty(itemsSource)) { throw new Exception(MessageStrings.ItemsAreEmpty); } IEnumerable<XElement> elementsBetween = TraverseUtils.ElementsBetween(startElement, endRepeater).ToList(); var repeaterTag = new RepeaterTag { Source = itemsSource, StartRepeater = startElement, EndRepeater = endRepeater, MakeElementCallback = MakeElementCallback }; var repeaterProcessor = new RepeaterProcessor { RepeaterTag = repeaterTag, }; if (elementsBetween.Any()) { this.GoDeeper(repeaterProcessor, elementsBetween.First()); } parentProcessor.AddProcessor(repeaterProcessor); return endRepeater; }