using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using CliWrap; namespace InnovEnergy.RemoteSupportConsole; public static class ObservablePipeSource { // TODO: move to utils? public static PipeSource AsPipeSource(this IObservable observable) { return PipeSource.Create((destination, cancellationToken) => observable .Select(data => destination.WriteAsync(data, 0, data.Length, cancellationToken)) .ToTask(cancellationToken) ); } }