Esempio n. 1
0
        /// <summary>
        /// Adapts a <see cref="Stream"/> into a <see cref="IReadableChannel"/>.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static IReadableChannel AsReadableChannel(this Stream stream, CancellationToken cancellationToken)
        {
            var streamAdaptor = new UnownedBufferStream(stream);

            streamAdaptor.Produce(cancellationToken);
            return(streamAdaptor.Channel);
        }
Esempio n. 2
0
        /// <summary>
        /// Adapts a <see cref="Stream"/> into a <see cref="IPipelineReader"/>.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static IPipelineReader AsPipelineReader(this Stream stream, CancellationToken cancellationToken)
        {
            if (stream is IPipelineReader)
            {
                return (IPipelineReader)stream;
            }

            var streamAdaptor = new UnownedBufferStream(stream);
            streamAdaptor.Produce(cancellationToken);
            return streamAdaptor.Reader;
        }
Esempio n. 3
0
        /// <summary>
        /// Adapts a <see cref="Stream"/> into a <see cref="IPipelineReader"/>.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static IPipelineReader AsPipelineReader(this Stream stream, CancellationToken cancellationToken)
        {
            if (stream is IPipelineReader)
            {
                return((IPipelineReader)stream);
            }

            var streamAdaptor = new UnownedBufferStream(stream);

            streamAdaptor.Produce(cancellationToken);
            return(streamAdaptor.Reader);
        }