Пример #1
0
		internal AXmlReader(ObjectIterator objectIterator, XmlReaderSettings settings = null)
		{
			this.objectIterator = objectIterator;
			this.settings = settings ?? new XmlReaderSettings();
			this.nameTable = this.settings.NameTable ?? new NameTable();
			this.nsManager = new XmlNamespaceManager(this.nameTable);
			objectIterator.StopAtElementEnd = true;
		}
Пример #2
0
 internal AXmlReader(ObjectIterator objectIterator, XmlReaderSettings settings = null)
 {
     this.objectIterator             = objectIterator;
     this.settings                   = settings ?? new XmlReaderSettings();
     this.nameTable                  = this.settings.NameTable ?? new NameTable();
     this.nsManager                  = new XmlNamespaceManager(this.nameTable);
     objectIterator.StopAtElementEnd = true;
 }
        public List <InternalObject> ReadAllObjectsIncremental(InternalObject[] oldObjects, List <UnchangedSegment> reuseMap, CancellationToken cancellationToken)
        {
            ObjectIterator oldObjectIterator = new ObjectIterator(oldObjects);
            int            reuseMapIndex     = 0;

            while (reuseMapIndex < reuseMap.Count)
            {
                var reuseEntry = reuseMap[reuseMapIndex];
                while (this.CurrentLocation < reuseEntry.NewOffset)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    ReadObject();
                }
                if (this.CurrentLocation >= reuseEntry.NewOffset + reuseEntry.Length)
                {
                    reuseMapIndex++;
                    continue;
                }
                Debug.Assert(reuseEntry.NewOffset <= this.CurrentLocation && this.CurrentLocation < reuseEntry.NewOffset + reuseEntry.Length);
                // reuse the nodes within this reuseEntry starting at oldOffset:
                int oldOffset = this.CurrentLocation - reuseEntry.NewOffset + reuseEntry.OldOffset;
                // seek to oldOffset in the oldObjects array:
                oldObjectIterator.SkipTo(oldOffset);
                if (oldObjectIterator.CurrentPosition == oldOffset)
                {
                    // reuse old objects within this reuse entry:
                    int reuseEnd = reuseEntry.OldOffset + reuseEntry.Length;
                    while (oldObjectIterator.CurrentObject != null && oldObjectIterator.CurrentPosition + oldObjectIterator.CurrentObject.LengthTouched < reuseEnd)
                    {
                        StoreObject(oldObjectIterator.CurrentObject);
                        Skip(oldObjectIterator.CurrentObject.Length);
                        oldObjectIterator.MoveNext();
                    }
                    reuseMapIndex++;                     // go to next re-use map
                }
                else
                {
                    // We are in a region where old objects are available, but aren't aligned correctly.
                    // Don't skip this reuse entry, and read a single object so that we can re-align
                    ReadObject();
                }
            }
            while (HasMoreData())
            {
                cancellationToken.ThrowIfCancellationRequested();
                ReadObject();
            }
            return(objects);
        }
Пример #4
0
		public List<InternalObject> ReadAllObjectsIncremental(InternalObject[] oldObjects, List<UnchangedSegment> reuseMap, CancellationToken cancellationToken)
		{
			ObjectIterator oldObjectIterator = new ObjectIterator(oldObjects);
			int reuseMapIndex = 0;
			while (reuseMapIndex < reuseMap.Count) {
				var reuseEntry = reuseMap[reuseMapIndex];
				while (this.CurrentLocation < reuseEntry.NewOffset) {
					cancellationToken.ThrowIfCancellationRequested();
					ReadObject();
				}
				if (this.CurrentLocation >= reuseEntry.NewOffset + reuseEntry.Length) {
					reuseMapIndex++;
					continue;
				}
				Debug.Assert(reuseEntry.NewOffset <= this.CurrentLocation && this.CurrentLocation < reuseEntry.NewOffset + reuseEntry.Length);
				// reuse the nodes within this reuseEntry starting at oldOffset:
				int oldOffset = this.CurrentLocation - reuseEntry.NewOffset + reuseEntry.OldOffset;
				// seek to oldOffset in the oldObjects array:
				oldObjectIterator.SkipTo(oldOffset);
				if (oldObjectIterator.CurrentPosition == oldOffset) {
					// reuse old objects within this reuse entry:
					int reuseEnd = reuseEntry.OldOffset + reuseEntry.Length;
					while (oldObjectIterator.CurrentObject != null && oldObjectIterator.CurrentPosition + oldObjectIterator.CurrentObject.LengthTouched < reuseEnd) {
						StoreObject(oldObjectIterator.CurrentObject);
						Skip(oldObjectIterator.CurrentObject.Length);
						oldObjectIterator.MoveNext();
					}
					reuseMapIndex++; // go to next re-use map
				} else {
					// We are in a region where old objects are available, but aren't aligned correctly.
					// Don't skip this reuse entry, and read a single object so that we can re-align
					ReadObject();
				}
			}
			while (HasMoreData()) {
				cancellationToken.ThrowIfCancellationRequested();
				ReadObject();
			}
			return objects;
		}