20 lines
549 B
C#
20 lines
549 B
C#
|
using System.Reactive.Linq;
|
||
|
using System.Reactive.Threading.Tasks;
|
||
|
using CliWrap;
|
||
|
|
||
|
namespace InnovEnergy.App.RemoteSupportConsole;
|
||
|
|
||
|
public static class ObservablePipeSource
|
||
|
{
|
||
|
|
||
|
// TODO: move to utils?
|
||
|
|
||
|
public static PipeSource AsPipeSource(this IObservable<Byte[]> observable)
|
||
|
{
|
||
|
return PipeSource.Create((destination, cancellationToken) =>
|
||
|
observable
|
||
|
.Select(data => destination.WriteAsync(data, 0, data.Length, cancellationToken))
|
||
|
.ToTask(cancellationToken)
|
||
|
);
|
||
|
}
|
||
|
}
|