Ejemplo n.º 1
0
 /// <summary>
 /// Parses a document.
 /// </summary>
 public AXmlDocument Parse(ITextSource textSource, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (textSource == null)
         throw new ArgumentNullException("textSource");
     var reader = new TagReader(this, textSource, true);
     var internalObjects = reader.ReadAllObjects(cancellationToken);
     var heuristic = new TagMatchingHeuristics(textSource);
     return new AXmlDocument(null, 0, heuristic.CreateDocument(internalObjects, cancellationToken));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses a document incrementally into a flat list of tags.
        /// </summary>
        /// <param name="oldParserState">The parser state from a previous call to ParseIncremental(). Use null for the first call.</param>
        /// <param name="newTextSource">The text source for the new document version.</param>
        /// <param name="newParserState">Out: the new parser state, pass this to the next ParseIncremental() call.</param>
        /// <param name="cancellationToken">Optional: cancellation token.</param>
        /// <returns>Parsed tag soup.</returns>
        public AXmlDocument ParseIncremental(
			IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
			CancellationToken cancellationToken = default(CancellationToken))
        {
            if (newTextSource == null)
                throw new ArgumentNullException("newTextSource");
            var internalObjects = InternalParseIncremental(oldParserState, newTextSource, out newParserState, true, cancellationToken);
            var heuristic = new TagMatchingHeuristics(newTextSource);
            return new AXmlDocument(null, 0, heuristic.CreateDocument(internalObjects, cancellationToken));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses a document.
        /// </summary>
        public AXmlDocument Parse(ITextSource textSource, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (textSource == null)
            {
                throw new ArgumentNullException("textSource");
            }
            var reader          = new TagReader(this, textSource, true);
            var internalObjects = reader.ReadAllObjects(cancellationToken);
            var heuristic       = new TagMatchingHeuristics(textSource);

            return(new AXmlDocument(null, 0, heuristic.CreateDocument(internalObjects, cancellationToken)));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses a document incrementally into a flat list of tags.
        /// </summary>
        /// <param name="oldParserState">The parser state from a previous call to ParseIncremental(). Use null for the first call.</param>
        /// <param name="newTextSource">The text source for the new document version.</param>
        /// <param name="newParserState">Out: the new parser state, pass this to the next ParseIncremental() call.</param>
        /// <param name="cancellationToken">Optional: cancellation token.</param>
        /// <returns>Parsed tag soup.</returns>
        public AXmlDocument ParseIncremental(
            IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (newTextSource == null)
            {
                throw new ArgumentNullException("newTextSource");
            }
            var internalObjects = InternalParseIncremental(oldParserState, newTextSource, out newParserState, true, cancellationToken);
            var heuristic       = new TagMatchingHeuristics(newTextSource);

            return(new AXmlDocument(null, 0, heuristic.CreateDocument(internalObjects, cancellationToken)));
        }