Exemplo n.º 1
0
        private IEnumerable <IHtmlMarkup> GetTagElement(IHtmlContent content, RefIndex refIndex)
        {
            var matchResult = _startRegex.Match(content.Content.ToString());
            var name        = matchResult.Groups[1].Value;

            refIndex.Index = matchResult.Index;
            if (content.CurrentChar == '>')
            {
                yield return(new Tag(content.Content.ToString(), name, Array.Empty <IAttribute>(), GetElements(name, CloneContent(content))));

                yield break;
            }

            var          beginPosition  = refIndex.Index + (matchResult.Length) + content.From; // {from}this is test code <div{beginPosition} name='4'>{index}
            IHtmlContent currentContent = content;

            if (beginPosition < content.Index)
            {
                currentContent =
                    new HtmlContent(content.RootContent.Substring(beginPosition, content.Index - beginPosition));
            }
            var attributes = new AttributeCollection(GetAttributes(currentContent)).ToArray();

            yield return(new Tag(content.Content.ToString(), name, attributes, GetElements(name, CloneContent(currentContent))));
        }
Exemplo n.º 2
0
        public object Clone()
        {
            var result = new HtmlContent(this.RootContent)
            {
                From  = this.From,
                Index = this.Index
            };

            result.SetContent(this.Content);
            return(result);
        }
Exemplo n.º 3
0
 public AttributeCollection(string content)
 {
     this._content = new HtmlContent(content);
 }