Exemplo n.º 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);
        }
Exemplo n.º 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));
 }
Exemplo 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));
 }
Exemplo n.º 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);
		}
Exemplo n.º 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));
        }
Exemplo n.º 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)));
        }
Exemplo n.º 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;
		}