コード例 #1
0
        public PlaybackStreamBuilder SetCurrentDateTimeSource(ICurrentDateTimeSource value)
        {
            if (value == null)
                throw new ArgumentNullException("value");

            _currentDateTimeSource = value;

            return this;
        }
コード例 #2
0
ファイル: RollingMemory.cs プロジェクト: RedNacho/Sws.Streams
        public RollingMemory(
            IWriteStreamFactory writeStreamFactory,
            IWriteStreamToReadStreamConverter writeStreamToReadStreamConverter,
            IStreamDataSourceDisposerFactory writeStreamDataSourceDisposerFactory,
            IStreamDataSourceDisposerFactory readStreamDataSourceDisposerFactory,
            IRollingMemoryStateMonitor rollingMemoryStateMonitor,
            long? maximumAllowedWriteStreamBytes, TimeSpan? maximumAllowedUnavailableAge,
            long? maximumAllowedUnavailableBytes, ICurrentDateTimeSource currentDateTimeSource)
        {

            var readStreamQueue = new ReadStreamQueue();

            var dataSourceDisposerRegister = new DataSourceDisposerRegister();

            var completedWriteStreamBuffer = new CompletedWriteStreamBuffer(
                readStreamQueue,
                writeStreamToReadStreamConverter,
                readStreamDataSourceDisposerFactory,
                dataSourceDisposerRegister,
                maximumAllowedWriteStreamBytes);

            var rollingMemoryWriteStream = new RollingMemoryWriteStream(
                writeStreamFactory,
                completedWriteStreamBuffer,
                completedWriteStreamBuffer,
                currentDateTimeSource,
                writeStreamDataSourceDisposerFactory,
                dataSourceDisposerRegister,
                rollingMemoryStateMonitor);

            var readStreamQueueRefresher = new ReadStreamQueueRefresher(
                rollingMemoryWriteStream,
                completedWriteStreamBuffer,
                maximumAllowedUnavailableAge,
                maximumAllowedUnavailableBytes);

            var completedReadStreamHandler = new CompletedReadStreamHandler(
                dataSourceDisposerRegister);

            var rollingMemoryReadStream = new RollingMemoryReadStream(
                readStreamQueue,
                readStreamQueueRefresher,
                completedReadStreamHandler,
                rollingMemoryStateMonitor);

            _readStream = rollingMemoryReadStream;

            _writeStream = rollingMemoryWriteStream;

            _completedWriteStreamBuffer = completedWriteStreamBuffer;
        }
コード例 #3
0
        public RecordingStream(Stream targetStream, ICurrentDateTimeSource currentDateTimeSource, DateTime constructionTimestamp)
        {
            if (targetStream == null)
                throw new ArgumentException("targetStream");

            if (currentDateTimeSource == null)
                throw new ArgumentNullException("currentDateTimeSource");

            _targetStream = targetStream;

            _currentDateTimeSource = currentDateTimeSource;

            _constructionTimestamp = constructionTimestamp;
        }
コード例 #4
0
        public PlaybackStream(Stream sourceStream, ICurrentDateTimeSource currentDateTimeSource, DateTime constructionTimestamp)
        {
            if (sourceStream == null)
                throw new ArgumentNullException("sourceStream");

            if (currentDateTimeSource == null)
                throw new ArgumentNullException("currentDateTimeSource");

            _sourceStream = sourceStream;

            _currentDateTimeSource = currentDateTimeSource;

            _constructionTimestamp = constructionTimestamp;

            CurrentPlaybackState = new ReadingTimeOffsetPlaybackState();
        }
コード例 #5
0
        public RollingMemoryWriteStream(IWriteStreamFactory targetFactory,
            ICompletedWriteStreamHandler completedWriteStreamHandler,
            IWriteStreamLengthValidator activeWriteStreamLengthValidator,
            ICurrentDateTimeSource currentDateTimeSource,
            IStreamDataSourceDisposerFactory writeStreamDataSourceDisposerFactory,
            IDataSourceDisposerRegister dataSourceDisposerRegister,
            IRollingMemoryStateMonitor rollingMemoryStateMonitor)
        {
            _targetFactory = targetFactory;

            _completedWriteStreamHandler = completedWriteStreamHandler;

            _activeWriteStreamLengthValidator = activeWriteStreamLengthValidator;

            _currentDateTimeSource = currentDateTimeSource;

            _writeStreamDataSourceDisposerFactory = writeStreamDataSourceDisposerFactory;

            _dataSourceDisposerRegister = dataSourceDisposerRegister;

            _rollingMemoryStateMonitor = rollingMemoryStateMonitor;
        }
コード例 #6
0
        /// <summary>
        /// Allows the default CurrentDateTimeSource to be overridden.  This simply provides the current
        /// DateTime from the system; the ability to override it is provided to facilitate unit testing.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>

        public RollingMemoryBuilder SetCurrentDateTimeSource(ICurrentDateTimeSource value)
        {
            if (value == null)
                throw new ArgumentNullException("value");

            _currentDateTimeSource = new Lazy<ICurrentDateTimeSource>(() => value, true);

            return this;
        }