/// <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); }
/// <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; }
/// <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); }