本文整理汇总了C#中IObservable.AssertNotNull方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.AssertNotNull方法的具体用法?C# IObservable.AssertNotNull怎么用?C# IObservable.AssertNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObservable
的用法示例。
在下文中一共展示了IObservable.AssertNotNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExerciseViewModel
public ExerciseViewModel(ISchedulerService schedulerService, Exercise model, IObservable<ExecutionContext> executionContext)
{
schedulerService.AssertNotNull(nameof(schedulerService));
model.AssertNotNull(nameof(model));
executionContext.AssertNotNull(nameof(executionContext));
this.disposables = new CompositeDisposable();
this.model = model;
executionContext
.ObserveOn(schedulerService.MainScheduler)
.Subscribe(x => this.ExecutionContext = x)
.AddTo(this.disposables);
Observable
.CombineLatest(
this
.WhenAnyValue(x => x.ExecutionContext)
.Select(ec => ec == null ? Observable.Never<TimeSpan>() : ec.WhenAnyValue(x => x.SkipAhead))
.Switch(),
this
.WhenAnyValue(x => x.ExecutionContext)
.Select(ec => ec == null ? Observable.Never<Exercise>() : ec.WhenAnyValue(x => x.CurrentExercise))
.Switch(),
(skip, current) => skip == TimeSpan.Zero && current == this.model)
.ObserveOn(schedulerService.MainScheduler)
.Subscribe(x => this.IsActive = x)
.AddTo(this.disposables);
this
.WhenAnyValue(x => x.ExecutionContext)
.Select(
ec =>
ec == null
? Observable.Return(TimeSpan.Zero)
: ec
.WhenAnyValue(x => x.CurrentExerciseProgress)
.Where(_ => ec.CurrentExercise == this.model)
.StartWith(TimeSpan.Zero))
.Switch()
.ObserveOn(schedulerService.MainScheduler)
.Subscribe(x => this.ProgressTimeSpan = x)
.AddTo(this.disposables);
this
.WhenAny(
x => x.Duration,
x => x.ProgressTimeSpan,
(duration, progressTimeSpan) => progressTimeSpan.Value.TotalMilliseconds / duration.Value.TotalMilliseconds)
.Select(progressRatio => double.IsNaN(progressRatio) || double.IsInfinity(progressRatio) ? 0d : progressRatio)
.Select(progressRatio => Math.Min(1d, progressRatio))
.Select(progressRatio => Math.Max(0d, progressRatio))
.ObserveOn(schedulerService.MainScheduler)
.Subscribe(x => this.Progress = x)
.AddTo(this.disposables);
}