Beispiel #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);
        }
Beispiel #2
0
 /// <summary>
 /// Checks whether the given name is a valid XML name.
 /// </summary>
 public static bool IsValidXmlName(string name)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentException("The XML name cannot be null, empty or consist solely of white space", "name");
     }
     return(TagReader.IsValidName(name));
 }
Beispiel #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));
 }
Beispiel #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);
		}
Beispiel #5
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));
        }
Beispiel #6
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)));
        }
Beispiel #7
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;
		}