本文整理汇总了C#中IReactiveCommand.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# IReactiveCommand.SelectMany方法的具体用法?C# IReactiveCommand.SelectMany怎么用?C# IReactiveCommand.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReactiveCommand
的用法示例。
在下文中一共展示了IReactiveCommand.SelectMany方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TaxonManagementVM
public TaxonManagementVM(
IConnectivityService Connectivity,
ITaxonService Taxa,
IDiversityServiceClient Service,
INotificationService Notification
) {
this.Connectivity = Connectivity;
this.Service = Service;
this.Taxa = Taxa;
this.Notification = Notification;
_IsOnlineAvailable = this.ObservableToProperty(Connectivity.WifiAvailable(), x => x.IsOnlineAvailable);
var localLists =
this.FirstActivation()
.SelectMany(_ =>
Taxa.getTaxonSelections()
.ToObservable(ThreadPoolScheduler.Instance)
.Select(list => new TaxonListVM(list)))
.Publish();
LocalLists =
localLists
.ObserveOnDispatcher()
.CreateCollection();
var onlineLists =
localLists
.IgnoreElements() //only download lists once the local ones are loaded
.Concat(Observable.Return(null as TaxonListVM))
.CombineLatest(this.OnActivation(), (_, _2) => _2)
.CheckConnectivity(Connectivity, Notification)
.SelectMany(_ => {
return Service.GetTaxonLists()
.DisplayProgress(Notification, DiversityResources.TaxonManagement_State_DownloadingLists)
.TakeUntil(this.OnDeactivation());
})
.ObserveOnDispatcher()
.SelectMany(lists =>
lists.Where(list => !LocalLists.Any(loc => loc.Model == list)) // Filter lists already present locally
.Select(list => new TaxonListVM(list))
)
.Publish();
PersonalLists =
onlineLists.Where(vm => !vm.Model.IsPublicList)
.CreateCollection();
PublicLists =
onlineLists.Where(vm => vm.Model.IsPublicList)
.CreateCollection();
onlineLists.Connect();
localLists.Connect();
Select = new ReactiveCommand<TaxonListVM>(vm => !vm.IsSelected && !vm.IsDownloading);
Select.Subscribe(taxonlist => {
foreach (var list in LocalLists) {
if (list.Model.TaxonomicGroup == taxonlist.Model.TaxonomicGroup)
list.Model.IsSelected = false;
}
Taxa.selectTaxonList(taxonlist.Model);
});
Download = new ReactiveCommand<TaxonListVM>(vm => !vm.IsDownloading);
Download
.CheckConnectivity(Connectivity, Notification)
.Subscribe(taxonlist => {
if (Taxa.getTaxonTableFreeCount() > 0) {
CurrentPivot = Pivot.Local;
taxonlist.IsDownloading = true;
makeListLocal(taxonlist);
DownloadTaxonList(taxonlist)
.DisplayProgress(Notification, DiversityResources.TaxonManagement_State_DownloadingList)
.ObserveOnDispatcher()
.ShowServiceErrorNotifications(Notification)
.Subscribe(_ => {
//Download Succeeded
taxonlist.IsDownloading = false;
if (Select.CanExecute(taxonlist))
Select.Execute(taxonlist);
},
_ => //Download Failed
{
taxonlist.IsDownloading = false;
removeLocalList(taxonlist);
},
() =>
{
});
}
});
Delete = new ReactiveCommand<TaxonListVM>(vm => !vm.IsDownloading);
//.........这里部分代码省略.........