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


C# ReactiveList.SuppressChangeNotifications方法代码示例

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


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

示例1: PersonListViewModel

 public PersonListViewModel(IScreen hostScreen, IPersonRepository personRepository = null)
 {
     HostScreen = hostScreen;
     personRepository = personRepository ?? new PersonRepository();
     Persons = new ReactiveList<PersonItemViewModel>();
     NewPersonCommand = new ReactiveCommand(null);
     NewPersonCommand.RegisterAsyncAction(_ => { }).Subscribe(_ => HostScreen.Router.Navigate.Execute(new PersonAddViewModel(HostScreen)));
     RefreshCommand = new ReactiveCommand(null);
     var refresh = RefreshCommand.RegisterAsync<List<Person>>(_ => Observable.Start(() => personRepository.RetrievePersonsAsync().
                                                                                                           Result));
     refresh.Subscribe(list =>
     {
         using (Persons.SuppressChangeNotifications())
         {
             Persons.Clear();
             Persons.AddRange(personRepository.RetrievePersonsAsync().
                                               Result.Select(d => new PersonItemViewModel(d.FirstName,
                                                                      d.LastName,
                                                                      d.Age)));
         }
     });
     MessageBus.Current.Listen<Person>().
                Subscribe(p =>
                {
                    personRepository.AddPerson(p);
                    RefreshCommand.Execute(null);
                });
 }
开发者ID:jiravanet,项目名称:Prezentace-ReactiveUI,代码行数:28,代码来源:PersonListViewModel.cs

示例2: NotificationsListViewModel

        public NotificationsListViewModel(INotificationsClient notificationsApi)
        {
            Notifications = new ReactiveList<NotificationTileViewModel>();
            LoadNotifications = new ReactiveCommand();

            var loadedNotifications = LoadNotifications.RegisterAsync(_ =>
                //BlobCache.LocalMachine.GetAndFetchLatest("notifications", () => Observable.Return(new List<Notification>())));
                BlobCache.LocalMachine.GetAndFetchLatest("notifications", () =>
                    notificationsApi.GetAllForCurrent()));

            loadedNotifications.Subscribe(newItems => {
                using (Notifications.SuppressChangeNotifications()) {
                    var toAdd = newItems
                        .Where(x => x.Repository.Owner.Id != 9919 && x.Repository.Owner.Id != 1089146)
                        .Select(x => new NotificationTileViewModel(x))
                        .ToArray();

                    Notifications.Clear();
                    Notifications.AddRange(toAdd);
                    //Notifications.AddRange(new[] { new NotificationTileViewModel(null) });
                }
            });
        }
开发者ID:paulcbetts,项目名称:starter-sample,代码行数:23,代码来源:NotificationsListViewModel.cs

示例3: MainWindowViewModel

        public MainWindowViewModel()
        {
            ReleasesListHint = "Type in a release location URL or path to files";
            ReleasesList = new ReactiveList<ReleaseEntryViewModel>();
            ReleasesList.ChangeTrackingEnabled = true;

            CheckRemoteUpdateInfo = ReactiveCommand.CreateAsyncTask(
                this.WhenAny(x => x.ReleaseLocation, x => !String.IsNullOrWhiteSpace(x.Value)),
                async _ => {
                    ReleasesListHint = "";

                    var releaseData = default(String);
                    if (Regex.IsMatch(ReleaseLocation, "^https?://", RegexOptions.IgnoreCase)) {
                        var wc = new WebClient();
                        releaseData = await wc.DownloadStringTaskAsync(ReleaseLocation + "/RELEASES");
                    } else {
                        releaseData = File.ReadAllText(releaseData, Encoding.UTF8);
                    }

                    var ret = releaseData.Split('\n')
                        .Select(x => ReleaseEntry.ParseReleaseEntry(x))
                        .ToList();

                    return ret;
                });

            CheckRemoteUpdateInfo.ThrownExceptions
                .Subscribe(ex => ReleasesListHint = "Failed to check for updates: " + ex.Message);

            CheckRemoteUpdateInfo
                .Subscribe(x => {
                    var vms = x
                        .Where(y => y.IsDelta == false)
                        .Select(y => new ReleaseEntryViewModel(y));

                    using (ReleasesList.SuppressChangeNotifications()) {
                        ReleasesList.Clear();
                        ReleasesList.AddRange(vms);
                    }
                });

            this.WhenAnyValue(x => x.ReleaseLocation)
                .Throttle(TimeSpan.FromMilliseconds(750), RxApp.MainThreadScheduler)
                .InvokeCommand(CheckRemoteUpdateInfo);

            ReleasesList.ItemChanged
                .Where(x => x.PropertyName == "CurrentAction")
                .Subscribe(x => updateStartsAndEnds(x.Sender));

            DoIt = ReactiveCommand.CreateAsyncTask(
                this.WhenAny(x => x.ReleasesList.Count, x => x.Value > 0),
                async _ => {
                    var releasesToApply = ReleasesList.Where(x => x.Enabled).ToList();
                    if (releasesToApply.Count < 1 || releasesToApply.All(x => x.CurrentAction == ReleaseEntryActions.None)) {
                        await UserError.Throw(new OkUserError("Nothing to do", "At least one release must have the 'Start' action"));
                        return;
                    }

                    var appName = ReleasesList[0].Name;
                    var rootAppDir = Environment.ExpandEnvironmentVariables("%LocalAppData%\\" + appName);

                    if (Directory.Exists(rootAppDir)) {
                        var result = await UserError.Throw(new YesNoUserError(
                            "App already installed",
                            String.Format("App '{0}' is already installed, remove it before running install?", appName)));

                        if (result == RecoveryOptionResult.CancelOperation) {
                            return;
                        }

                        if (result == RecoveryOptionResult.RetryOperation) {
                            using (var mgr = new UpdateManager(null, appName, Environment.ExpandEnvironmentVariables("%LocalAppData%"))) {
                                await mgr.FullUninstall();
                            }
                        }
                    }

                    foreach (var release in releasesToApply) {
                        release.ReleaseLocation = this.ReleaseLocation;
                        await release.ApplyThisRelease.ExecuteAsync(null);
                    }
                });
        }
开发者ID:Squirrel,项目名称:Squirrel.Windows.Tools,代码行数:83,代码来源:MainWindowViewModel.cs

示例4: NewGameViewModel

        public NewGameViewModel()
        {
            Players = new ReactiveList<string>();

            var canStart = this.Players.CountChanged.Select(count => count >= 3);
            StartGame = ReactiveCommand.Create(() => { }, canStart);
            RandomizeOrder = ReactiveCommand.Create(() => {
                    using (Players.SuppressChangeNotifications()) {
                        var r = new Random();
                        var newOrder = Players.OrderBy(x => r.NextDouble()).ToList();
                        Players.Clear();
                        Players.AddRange(newOrder);
                    }
                },
                canStart);

            RemovePlayer = ReactiveCommand.Create<string>(player => this.Players.Remove(player));
            var canAddPlayer = this.WhenAnyValue(x => x.Players.Count, x => x.NewPlayerName,
                (count, newPlayerName) => count < 7 && !string.IsNullOrWhiteSpace(newPlayerName) && !this.Players.Contains(newPlayerName));
            AddPlayer = ReactiveCommand.Create(() => {
                    Players.Add(NewPlayerName.Trim());
                    NewPlayerName = string.Empty;
                },
                canAddPlayer);
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:25,代码来源:ObservedChangedMixinTest.cs


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