Example #1
0
        List <InternalObject> InternalParseIncremental(
            IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
            bool collapseProperlyNestedElements, CancellationToken cancellationToken)
        {
            var reader = new TagReader(this, newTextSource, collapseProperlyNestedElements);
            ITextSourceVersion newVersion = newTextSource.Version;
            var reuseMap = oldParserState != null?oldParserState.GetReuseMapTo(newVersion) : null;

            List <InternalObject> internalObjects;

            if (reuseMap != null)
            {
                internalObjects = reader.ReadAllObjectsIncremental(oldParserState.Objects, reuseMap, cancellationToken);
            }
            else
            {
                internalObjects = reader.ReadAllObjects(cancellationToken);
            }

            if (newVersion != null)
            {
                newParserState = new IncrementalParserState(newTextSource.TextLength, newVersion, internalObjects.ToArray());
            }
            else
            {
                newParserState = null;
            }

            return(internalObjects);
        }
Example #2
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));
 }
Example #3
0
		/// <summary>
		/// Parses a document into a flat list of tags.
		/// </summary>
		/// <returns>Parsed tag soup.</returns>
		public IList<AXmlObject> ParseTagSoup(ITextSource textSource,
		                                      CancellationToken cancellationToken = default(CancellationToken))
		{
			if (textSource == null)
				throw new ArgumentNullException("textSource");
			var reader = new TagReader(this, textSource, false);
			var internalObjects = reader.ReadAllObjects(cancellationToken);
			return CreatePublic(internalObjects);
		}
Example #4
0
        /// <summary>
        /// Parses a document into a flat list of tags.
        /// </summary>
        /// <returns>Parsed tag soup.</returns>
        public IList <AXmlObject> ParseTagSoup(ITextSource textSource,
                                               CancellationToken cancellationToken = default(CancellationToken))
        {
            if (textSource == null)
            {
                throw new ArgumentNullException("textSource");
            }
            var reader          = new TagReader(this, textSource, false);
            var internalObjects = reader.ReadAllObjects(cancellationToken);

            return(CreatePublic(internalObjects));
        }
Example #5
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)));
        }
Example #6
0
        List<InternalObject> InternalParseIncremental(
			IncrementalParserState oldParserState, ITextSource newTextSource, out IncrementalParserState newParserState,
			bool collapseProperlyNestedElements, CancellationToken cancellationToken)
        {
            var reader = new TagReader(this, newTextSource, collapseProperlyNestedElements);
            ITextSourceVersion newVersion = newTextSource.Version;
            var reuseMap = oldParserState != null ? oldParserState.GetReuseMapTo(newVersion) : null;

            List<InternalObject> internalObjects;
            if (reuseMap != null)
                internalObjects = reader.ReadAllObjectsIncremental(oldParserState.Objects, reuseMap, cancellationToken);
            else
                internalObjects = reader.ReadAllObjects(cancellationToken);

            if (newVersion != null)
                newParserState = new IncrementalParserState(newTextSource.TextLength, newVersion, internalObjects.ToArray());
            else
                newParserState = null;

            return internalObjects;
        }