当前位置: 首页>>代码示例>>C#>>正文


C# ReactiveList.RemoveAll方法代码示例

本文整理汇总了C#中ReactiveList.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList.RemoveAll方法的具体用法?C# ReactiveList.RemoveAll怎么用?C# ReactiveList.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReactiveList的用法示例。


在下文中一共展示了ReactiveList.RemoveAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecentViewModel

        public RecentViewModel(Guid id, string metaDataSlug, IEnumerable<RecentItemViewModel> recentItems) {
            _id = id;
            RecentItems = new ReactiveList<RecentItemViewModel>(recentItems);

            // TODO: This is a tab, and tabs are only active while shown
            // but we want to receive these events regardless of being active or not, otherwise we are not uptodate when the user switches to us.
            // Or we need to find a different approach!
            Listen<ContentUsed>()
                .Where(x => {
                    var contentId = GetId(x.Content);
                    lock (RecentItems)
                        return _id == x.Content.GameId && RecentItems.All(r => r.Id != contentId);
                })
                .Select(x => {
                    var ri = x.Content.MapTo<RecentItemViewModel>();
                    if (x.Token != null)
                        ri.UpdateExecute(x.Token);
                    return ri;
                })
                .ObserveOnMainThread()
                .Subscribe(x => {
                    lock (RecentItems)
                        RecentItems.Insert(0, x);
                });

            Listen<RecentItemRemoved>()
                .ObserveOnMainThread()
                .Subscribe(x => {
                    lock (RecentItems) {
                        RecentItems.RemoveAll(r => r.Id == x.Content.Id);
                    }
                });

            // TODO: Stop manually moving, start auto sorting in View (ICollectionView or ReactiveDerivedCollection)...
            // Then remove this event
            Listen<ContentUsed>()
                .Select(x => {
                    var contentId = GetId(x.Content);
                    lock (RecentItems)
                        return RecentItems.FirstOrDefault(r => r.Id == contentId);
                })
                .Where(x => x != null)
                .ObserveOnMainThread()
                .Subscribe(x => {
                    lock (RecentItems)
                        RecentItems.Move(RecentItems.IndexOf(x), 0);
                });

            AddContent =
                ReactiveCommand.CreateAsyncTask(
                    async x => await RequestAsync(new OpenWebLink(ViewType.Browse, metaDataSlug)).ConfigureAwait(false));


            this.WhenActivated(d => {
                RefreshUpdated();
                d(new TimerWithoutOverlap(TimeSpan.FromMinutes(1),
                    () => RxApp.MainThreadScheduler.Schedule(RefreshUpdated)));
            });
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:59,代码来源:RecentViewModel.cs

示例2: InstalledViewModel

        public InstalledViewModel(Guid id, string metaDataSlug, IEnumerable<InstalledItemViewModel> localContent) {
            _id = id;
            LocalContent = new ReactiveList<InstalledItemViewModel>(localContent) {ChangeTrackingEnabled = true};
            LocalContent.ItemChanged
                .Where(x => x.PropertyName == "IsEnabled")
                .ObserveOnMainThread()
                .Subscribe(x => {
                    if (x.Sender.IsEnabled)
                        EnabledItems.Add(x.Sender);
                    else
                        EnabledItems.Remove(x.Sender);
                });
            EnabledItems = new ReactiveList<InstalledItemViewModel>(LocalContent.Where(x => x.IsEnabled));

            AddContent =
                ReactiveCommand.CreateAsyncTask(
                    async x => await RequestAsync(new OpenWebLink(ViewType.Browse, metaDataSlug)).ConfigureAwait(false));
            _uninstallSelected =
                ReactiveCommand.CreateAsyncTask(async x => {
                    var r =
                        await
                            Cheat.DialogManager.MessageBoxAsync(
                                new MessageBoxDialogParams("Are you sure you wish to uninstall the selected mods?",
                                    "Uninstall items?", SixMessageBoxButton.OKCancel)).ConfigureAwait(false);
                    if (r != SixMessageBoxResult.OK)
                        return;
                    await RequestAsync(
                        new UninstallInstalledItems(id,
                            LocalContent.Where(x1 => x1.IsEnabled).Select(x2 => x2.Id).ToList()))
                        .ConfigureAwait(false);
                }).DefaultSetup("UninstallSelected");

            _playSelected =
                ReactiveCommand.CreateAsyncTask(async x => await RequestAsync(
                    new PlayInstalledItems(id,
                        LocalContent.Where(x1 => x1.IsEnabled).Select(x2 => x2.Id).ToList()))
                    .ConfigureAwait(false))
                    .DefaultSetup("PlaySelected");
            _clear =
                ReactiveCommand.CreateAsyncTask(async x => await ResetInternal().ConfigureAwait(false))
                    .DefaultSetup("Reset");

            // TODO: This is a tab, and tabs are only active while shown
            // but we want to receive these events regardless of being active or not, otherwise we are not uptodate when the user switches to us.
            // Or we need to find a different approach!
            Listen<LocalContentAdded>()
                .Where(x => _id == x.GameId)
                .Select(x => x.LocalContent.MapTo<List<InstalledItemViewModel>>())
                .ObserveOnMainThread()
                .Subscribe(x => LocalContent.AddRange(x));
            Listen<UninstallActionCompleted>()
                .Where(x => _id == x.Game.Id)
                .Select(x => x.UninstallLocalContentAction.Content.Select(u => u.Content.Id).ToArray())
                .ObserveOnMainThread()
                .Subscribe(
                    x =>
                        LocalContent.RemoveAll(
                            LocalContent.Where(
                                c => x.Contains(c.Id))
                                .ToArray()));
            /*
            this.WhenActivated(d => {
                d();
            });
            */
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:66,代码来源:InstalledViewModel.cs


注:本文中的ReactiveList.RemoveAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。