本文整理汇总了C#中ReactiveCommand.Where方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveCommand.Where方法的具体用法?C# ReactiveCommand.Where怎么用?C# ReactiveCommand.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReactiveCommand
的用法示例。
在下文中一共展示了ReactiveCommand.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MetroiLinksViewModel
public MetroiLinksViewModel()
{
OpenPageSelectorCommand = new ReactiveCommand();
OpenPageSelectorCommand
.Where(x => MetroiLink != null)
.Select(x => new Dialog.PageSelector())
.Subscribe(x =>
{
x.Show();
MessageBus.Current.SendMessage(CommunityProfiles, "pagesToSelect");
});
this.ObservableForProperty(x => x.MetroiLink)
.Subscribe(x =>
{
ShowEditor = x.Value != null;
NotShowEditor = !ShowEditor;
var cpRepo = new CommunityProfilesRepo();
if (x.Value != null)
CommunityProfiles = new ReactiveList<Page>(cpRepo.GetCommunityProfiles(x.Value.Client_ID));
});
CommunityProfiles = new ReactiveList<Page>();
NotShowEditor = !ShowEditor;
}
示例2: NowPlayingViewModel
public NowPlayingViewModel()
{
_playbackController = IoC.Get<PlaybackController>();
SelectionChangedCommand = new ReactiveCommand();
SelectionChangedCommand.Where(x => x != null)
.Select(x => ((IEnumerable) x).Cast<TrackStateViewModel>())
.Subscribe(x => SelectedItems = x);
RemoveSelectedCommand = new ReactiveCommand();
RemoveSelectedCommand.Subscribe(param =>
new List<TrackStateViewModel>(SelectedItems)
.ForEach(x => Playlist.Remove(x)));
RemoveAllCommand = new ReactiveCommand();
RemoveAllCommand.Subscribe(param => Playlist.Clear());
PlaySelectedCommand = new ReactiveCommand();
PlaySelectedCommand.Subscribe(param => _playbackController.Play(SelectedItems.First()));
}
示例3: MapManagementVM
public MapManagementVM(
IConnectivityService Network,
IMapTransferService MapService,
IMapStorageService MapStorage,
INotificationService Notifications,
[Dispatcher] IScheduler Dispatcher
) {
Contract.Requires(Network != null);
Contract.Requires(MapService != null);
Contract.Requires(MapStorage != null);
Contract.Requires(Notifications != null);
this.Network = Network;
this.MapService = MapService;
this.MapStorage = MapStorage;
this.FirstActivation()
.Subscribe(_ => getMaps.Execute(null));
MapList = getMaps.RegisterAsyncFunction(_ => MapStorage.getAllMaps().Select(m => new MapVM(m)))
.SelectMany(vms => vms.ToList())
.ObserveOn(Dispatcher)
.CreateCollection();
MapList.ItemsAdded
.Subscribe(item => _local_map_register.Add(item.ServerKey, Unit.Default));
MapList.ItemsRemoved
.Subscribe(item => _local_map_register.Remove(item.ServerKey));
SelectMap = new ReactiveCommand<MapVM>(vm => !vm.IsDownloading);
SelectMap
.Select(vm => vm as IElementVM<Map>)
.ToMessage(Messenger, MessageContracts.VIEW);
SelectMap
.Select(_ => Page.Previous)
.ToMessage(Messenger);
DeleteMap = new ReactiveCommand<MapVM>(vm => !vm.IsDownloading);
DeleteMap
.Do(vm => MapList.Remove(vm))
.Select(vm => vm.Model)
.Where(map => map != null)
.Subscribe(map => MapStorage.deleteMap(map));
_IsOnlineAvailable = this.ObservableToProperty(
this.OnActivation()
.SelectMany(Network.WifiAvailable().TakeUntil(this.OnDeactivation()))
.Do(x => { })
, x => x.IsOnlineAvailable, false);
SearchMaps = new ReactiveAsyncCommand(_IsOnlineAvailable);
_SearchResults = this.ObservableToProperty<MapManagementVM, IReactiveCollection<MapVM>>(
SearchMaps.RegisterAsyncFunction(s => searchMapsImpl(s as string))
.ObserveOn(Dispatcher)
.Select(result => {
try {
return new ReactiveCollection<MapVM>(result.Select(x => new MapVM(null) { ServerKey = x })) as IReactiveCollection<MapVM>;
}
catch (Exception) {
return null;
}
}),
x => x.SearchResults);
DownloadMap = new ReactiveCommand<MapVM>(vm => canBeDownloaded(vm as MapVM), Observable.Empty<Unit>());
DownloadMap
.Where(downloadMap.CanExecute)
.CheckConnectivity(Network, Notifications)
.Do(vm => vm.IsDownloading = true)
.Do(_ => CurrentPivot = Pivot.Local)
.Do(vm => MapList.Add(vm))
.Subscribe(downloadMap.Execute);
downloadMap.RegisterAsyncObservable(vm => {
var vm_t = vm as MapVM;
if (vm_t == null)
return Observable.Empty<System.Tuple<MapVM, Map>>();
else
return MapService.downloadMap(vm_t.ServerKey)
.ShowServiceErrorNotifications(Notifications)
.Catch((WebException ex) => {
Notifications.showNotification(DiversityResources.MapManagement_Message_NoPermissions);
return Observable.Empty<Map>();
})
.Select(map => System.Tuple.Create(vm_t, map));
})
.ObserveOn(Dispatcher)
.Select(t => {
if (t.Item1 != null) // VM
{
if (t.Item2 != null) // Map
{
t.Item1.SetModel(t.Item2);
}
else {
MapList.Remove(t.Item1);
//.........这里部分代码省略.........