Esempio n. 1
0
        /// <summary>
        ///		Restore reading position.
        /// </summary>
        /// <param name="position">
        ///		Position to restore.
        /// </param>
        /// <remarks>
        ///		The <paramref name="position"/> will usually contain positions for individual folders, in which case
        ///		the reader will be closed and position will be restored completely; regardless of the state of the reader
        ///		before the call to this method reader will get ready to read the folders from the <paramref name="position"/>.
        ///		However, the position may be used to store information about time and direction only
        ///		(<see cref="IReadingPosition.ContainsFolderPositions"/> will return <see langword="false"/> in this case).
        ///		In such scenario the reader will continue reading folders it was reading before the call to this method, only time
        ///		and direction will be changed.
        ///		If the <paramref name="position"/> does contain precise positions of individual folders, the full restoration
        ///		will be deferred and the outcome can be monitored by subscribing to <see cref="SeekStatus"/>.
        /// </remarks>
        /// <exception cref="ObjectDisposedException">
        ///		The reader has been disposed.
        /// </exception>
        /// <seealso cref="RepositoryReader.Position"/>
        /// <seealso cref="PositionRestoreStatusEventArgs"/>
        public void Seek(IReadingPosition position)
        {
            CheckNotDisposed();
            Check.Invariant(null != _position);

            Direction = position.Direction;

            if (!position.ContainsFolderPositions)
            {
                Seek(position.Time);
            }
            else
            {
                CloseReading();
                _position.Time = position.Time;

                IsPositioned = true;

                foreach (IFolderReadingPosition folderPosition in position.FolderPositions.Values)
                {
                    AddFolder(folderPosition);
                }

                // now all potent readers are in sorted offline queue
                // need to open, load and seek top file in the offline queue
                SyncOfflineQueueForReading();
            }
        }
Esempio n. 2
0
 /// <summary>
 ///		Make this position a copy of another position
 /// </summary>
 /// <param name="position">
 ///		The position to copy
 /// </param>
 public void CopyFrom(IReadingPosition position)
 {
     _positionsDictionary.Clear();
     this.Direction = position.Direction;
     this.Time      = position.Time;
     foreach (IFolderReadingPosition pos in position.FolderPositions.Values)
     {
         Add(pos);
     }
 }
Esempio n. 3
0
        /// <summary>
        ///		Get reader to contunue reading from the specified position.
        /// </summary>
        /// <param name="position">
        ///		The position to restore.
        /// </param>
        /// <param name="handler">
        ///		Receiver of the deferred position restoration messages.
        /// </param>
        /// <returns>
        ///		Reader which is ready to continue reading without returning duplicates.
        /// </returns>
        /// <remarks>
        ///		The <paramref name="position"/> must contain positions for individual folders (its
        ///		<see cref="IReadingPosition.ContainsFolderPositions"/> must return true).
        ///		The full position restoration will be deferred and the outcome can be monitored by subscribing to <see cref="SeekStatus"/>.
        /// </remarks>
        /// <seealso cref="IRepositoryReader.Seek(IReadingPosition)"/>
        /// <seealso cref="IRepositoryReader.Position"/>
        /// <seealso cref="PositionRestoreStatusEventArgs"/>
        /// <exception cref="ObjectDisposedException">
        ///		The repository has been disposed.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// </exception>
        /// <exception cref="InvalidOperationException">
        ///		The <paramref name="position"/> does not contain folder positions. You can create reader with <see cref="GetReader(IRepositoryFolder)"/>,
        ///		add more target folders with <see cref="IRepositoryReader.AddFolder(IRepositoryFolder)"/> and call
        ///		<see cref="IRepositoryReader.Seek(IReadingPosition)"/>.
        /// </exception>
        public virtual IRepositoryReader GetReader(IReadingPosition position, EventHandler <PositionRestoreStatusEventArgs> handler)
        {
            CheckHelper.CheckRepositoryNotDisposed(Repository);
            Check.DoRequireArgumentNotNull(position, "position");
            Check.DoCheckArgument(position.ContainsFolderPositions, () => StorageResources.ReaderTargetFoldersMissing);

            RepositoryReader retval = new RepositoryReader(Repository);

            Repository.RegisterReader(retval);
            if (handler != null)
            {
                retval.SeekStatus += handler;
            }
            retval.Seek(position);
            return(retval);
        }
 public void Seek(IReadingPosition position)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
 /// <summary>
 ///		Copy constructor.
 /// </summary>
 /// <param name="other">
 ///		The instance to copy.
 /// </param>
 public ReadingPosition(IReadingPosition other)
     : this()
 {
     CopyFrom(other);
 }