Event argument that specifies text range
Inheritance: System.EventArgs
Esempio n. 1
0
 private void OnParseBegin(object sender, HtmlParserRangeEventArgs e) {
     _startTime = DateTime.UtcNow;
     _rootNodeRecord = new ElementRecord(new RootNode(_tree));
     _currentElementRecord = null;
     _orphanedEndTagRecord = null;
     _elementStack = new Stack<ElementRecord>(16);
     _elementStack.Push(_rootNodeRecord);
 }
Esempio n. 2
0
        private void OnParseEnd(object sender, HtmlParserRangeEventArgs e) {
            // Collect all orphaned end tags since they belong to the currently
            // 
            CloseOrphanedEndTag(new TextRange(e.Range.End, 0), false);

            // Close all element that are still on the stack
            while (_elementStack.Count > 0) {
                ElementRecord elementRecord = _elementStack.Pop();

                ElementNode element = elementRecord.Element;
                ReadOnlyCollection<ElementNode> children = ElementNode.EmptyCollection;
                if (elementRecord.Children.Count > 0) {
                    children = new ReadOnlyCollection<ElementNode>(elementRecord.Children);
                }

                ReadOnlyCollection<AttributeNode> startTagAttributes = AttributeNode.EmptyCollection;
                if (elementRecord.StartTagAttributes.Count > 0) {
                    startTagAttributes = new ReadOnlyCollection<AttributeNode>(elementRecord.StartTagAttributes);
                }

                ReadOnlyCollection<AttributeNode> endTagAttributes = AttributeNode.EmptyCollection;
                if (elementRecord.EndTagAttributes.Count > 0) {
                    endTagAttributes = new ReadOnlyCollection<AttributeNode>(elementRecord.EndTagAttributes);
                }

                element.CompleteElement(TextRange.FromBounds(e.Range.End, e.Range.End), false, children, startTagAttributes, endTagAttributes);
            }

            _tree.RootNode = _rootNodeRecord.Element as RootNode;
            _rootNodeRecord = null;

            _tree.CommentCollection.Sort();

            var parser = sender as HtmlParser;
            _tree.DocType = parser.DocType;

            TreeBuildingTime = DateTime.UtcNow - _startTime;
        }
Esempio n. 3
0
 void OnEntity(object sender, HtmlParserRangeEventArgs e) {
     Log.AppendFormat("OnEntity: {0} ... {1}\r\n\r\n", e.Range.Start, e.Range.End);
 }