Currently I have the following block of Rx/ReactiveUI code:
this.WhenAnyValue(x => x.Listras)
.Where(item => item != null)
.Throttle(TimeSpan.FromMilliseconds(millis))
.ObserveOn(TaskPoolScheduler.Default)
.Select(im => GetArray.FromChannels(im, 0, 1))
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.Grayscale, out _grayscale);
this.WhenAnyValue(x => x.Grayscale)
.Where(item => item != null)
.Throttle(TimeSpan.FromMilliseconds(millis))
.ObserveOn(TaskPoolScheduler.Default)
.Select(ar => Gaussian.GaussianConvolution(ar, 1.5))
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.BlurMenor, out _blurMenor);
this.WhenAnyValue(x => x.BlurMenor)
.Where(item => item != null)
.Throttle(TimeSpan.FromMilliseconds(millis))
.ObserveOn(TaskPoolScheduler.Default)
.Select(ar => { ConversorImagem.Converter(ar, out BitmapSource im); return im; })
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.ImagemBlurMenor, out _imagemBlurMenor);
this.WhenAnyValue(x => x.BlurMenor)
.Where(item => item != null)
.Throttle(TimeSpan.FromMilliseconds(millis))
.ObserveOn(TaskPoolScheduler.Default)
.Select(ar => Gaussian.VerticalGaussianConvolution(ar, 5))
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.BlurMaior, out _blurMaior);
this.WhenAnyValue(x => x.BlurMaior)
.Where(item => item != null)
.Throttle(TimeSpan.FromMilliseconds(millis))
.ObserveOn(TaskPoolScheduler.Default)
.Select(ar => { ConversorImagem.Converter(ar, out BitmapSource im); return im; })
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.ImagemBlurMaior, out _imagemBlurMaior);
this.WhenAnyValue(x => x.BlurMenor, x => x.BlurMaior)
.Where(tuple => tuple.Item1 != null && tuple.Item2 != null)
.Throttle(TimeSpan.FromMilliseconds(millis))
.ObserveOn(TaskPoolScheduler.Default)
.Select(tuple => ArrayOperations.Diferença(tuple.Item1, tuple.Item2))
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.Diferença, out _diferença);
this.WhenAnyValue(x => x.Diferença)
.Where(item => item != null)
.Throttle(TimeSpan.FromMilliseconds(millis))
.ObserveOn(TaskPoolScheduler.Default)
.Select(ar => { ConversorImagem.Converter(ar, out BitmapSource im); return im; })
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.ImagemDiferença, out _imagemDiferença);
As you can see, it flagrantly violates the DRY principle, but I dont know how I could parameterize away the passing of properties and delegates.
What is the usual way of automating the creation of these method chains in Rx/ReactiveUI?