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


C# ReactiveList.Add方法代码示例

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


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

示例1: ViewModel2

        public ViewModel2()
        {
            SearchResults = new ReactiveList<FlickrPhoto>();
            var canSearch = this.WhenAny(x => x.SearchTerm, x => !String.IsNullOrWhiteSpace(x.Value));

            Search = ReactiveCommand.CreateAsyncTask(canSearch, async _ =>  {  return await GetSearchResultFromBing(this.SearchTerm); });
            LoadMoreItems = ReactiveCommand.CreateAsyncTask(canSearch, async x => { return await LoadMore((int)x);  });

            Search.Subscribe(results =>
            {
                SearchResults.Clear();
                foreach (var item in results)
                {
                    SearchResults.Add(item);
                }
            });

            LoadMoreItems.Subscribe(results =>
            {
                foreach (var item in results)
                {
                    SearchResults.Add(item);
                }
            });

            Search.ThrownExceptions.Subscribe(ex => { UserError.Throw("Potential network connectivity Error", ex); });
            LoadMoreItems.ThrownExceptions.Subscribe(ex => { UserError.Throw("Problem when downloading additional items", ex); });

            this.WhenAnyValue(x => x.SearchTerm)
                .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
                .InvokeCommand(this, x => x.Search);

            //SearchTerm = "british cat";
        }
开发者ID:afrog33k,项目名称:SharpPlayground,代码行数:34,代码来源:ViewModel2.cs

示例2: DemoListViewPageModel

        public DemoListViewPageModel()
        {
            DogViewModelList = new ReactiveList<DogsItemViewModel>();

            DogViewModelList.Add(new DogsItemViewModel() { Name = "Rex", Race = "German Sheppard" });
            DogViewModelList.Add(new DogsItemViewModel() { Name = "Barney", Race = "Poodle" });
            DogViewModelList.Add(new DogsItemViewModel() { Name = "Jimmy", Race = "Beagle" });
            DogViewModelList.Add(new DogsItemViewModel() { Name = "Rob", Race = "Labrador" });
        }
开发者ID:daniel-luberda,项目名称:DLToolkit.PageFactory,代码行数:9,代码来源:DemoListViewPageModel.cs

示例3: CacheViewModel

        public CacheViewModel(IScreen hostScreen, IAppState appState)
        {
            HostScreen = hostScreen;

            appState.WhenAny(x => x.CachePath, x => x.Value)
                .Where(x => !String.IsNullOrWhiteSpace(x))
                .Select(x => (new DirectoryInfo(x)).Name)
                .ToProperty(this, x => x.UrlPathSegment, out _UrlPathSegment);

            Keys = new ReactiveList<string>();
            appState.WhenAny(x => x.CurrentCache, x => x.Value)
                .SelectMany(x => Observable.Start(() => x.GetAllKeys(), RxApp.TaskpoolScheduler))
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(newKeys => {
                    Keys.Clear();
                    newKeys.ForEach(x => Keys.Add(x));
                });

            FilteredKeys = Keys.CreateDerivedCollection(
                key => key,
                key => FilterText == null || key.IndexOf(FilterText, StringComparison.OrdinalIgnoreCase) > -1,
                signalReset: this.WhenAny(x => x.FilterText, x => x.Value));

            SelectedViewer = "Text";

            this.WhenAny(x => x.SelectedKey, x => x.SelectedViewer, (k, v) => k.Value)
                .Where(x => x != null && SelectedViewer != null)
                .SelectMany(x => appState.CurrentCache.GetAsync(x).Catch(Observable.Return(default(byte[]))))
                .Select(x => createValueViewModel(x, SelectedViewer))
                .LoggedCatch(this, Observable.Return<ICacheValueViewModel>(null))
                .ToProperty(this, x => x.SelectedValue, out _SelectedValue);
        }
开发者ID:scbond,项目名称:AkavacheExplorer,代码行数:32,代码来源:CacheViewModel.cs

示例4: FlickrSearchViewModel

        public FlickrSearchViewModel(IImageService imageService)
        {
            Images = new ReactiveList<SearchResultViewModel>();

            var canExecute = this.WhenAnyValue(x => x.SearchText)
                .Select(x => !String.IsNullOrWhiteSpace(x));

            Search = ReactiveCommand.CreateAsyncObservable(
                canExecute,
                _ =>
                {
                    Images.Clear();
                    ShowError = false;
                    return imageService.GetImages(SearchText);
                });

            Search.Subscribe(images => Images.Add(images));

            Search.ThrownExceptions.Subscribe(_ => ShowError = true);

            isLoading = Search.IsExecuting.ToProperty(this, vm => vm.IsLoading);

            canEnterSearchText = this.WhenAnyValue(x => x.IsLoading)
                .Select(x => !x)
                .ToProperty(this, vm => vm.CanEnterSearchText);
        }
开发者ID:reactiveui-forks,项目名称:ReactiveFlickr,代码行数:26,代码来源:FlickrSearchViewModel.cs

示例5: MenuViewModel

 public MenuViewModel(IUserRepository userRepository)
 {
     if (userRepository == null) 
         throw new ArgumentNullException("userRepository");
     _userRepository = userRepository;
     Menu = new ReactiveList<MenuOptionViewModel>();
     // Use WhenAny to observe one or more values
     var canLoadMenu = this.WhenAny(m => m.User, user => user.Value != null);
     // hook function to command, shouldn't contain UI/complex logic
     LoadMenu = ReactiveCommand.CreateAsyncTask(canLoadMenu, _ => _userRepository.GetMenuByUser(User));
     // RxApp.MainThreadScheduler is our UI thread, you can go wild here
     LoadMenu.ObserveOn(RxApp.MainThreadScheduler).Subscribe(menu =>
     {
         Menu.Clear();
         foreach (var option in menu)
         {
             var menuOption = new MenuOptionViewModel(option);
             Menu.Add(menuOption);
         }
     });
     LoadMenu.ThrownExceptions.Subscribe(ex =>
     {
         Menu.Clear();
         MessageBox.Show(ex.Message);
     });
     // Use WhenAnyValue to check if a property was changed
     // If user was changed reload menu
     this.WhenAnyValue(m => m.User).InvokeCommand(this, vm => vm.LoadMenu);
 }
开发者ID:reactiveui-forks,项目名称:FirstsStepsRUI,代码行数:29,代码来源:MenuViewModel.cs

示例6: MainWindowModel

        public MainWindowModel()
        {
            _testDataSource = new TestDataSource();
            TestModels = new ReactiveList<TestModel>();

            TestViewModels = TestModels.CreateDerivedCollection(m =>
            {
                var vm = new TestViewModel
                {
                    Id = m.Id,
                    Name = m.Name,
                    OtherValue = "",
                    OriginalModel = m
                };
                vm.DoStuffWithThisCommand.Subscribe(x => DoStuff(x as TestViewModel));
                return vm;
            }, m => true, (m, vm) => 0);

            SetUpDataCommand = ReactiveCommand.CreateAsyncTask(_ => _testDataSource.GetTests());
            SetUpDataCommand.Subscribe(results =>
                {
                    using (SuppressChangeNotifications())
                    {
                        TestModels.Clear();
                        foreach (var model in results)
                            TestModels.Add(model);
                    }
                });
        }
开发者ID:reactiveui-forks,项目名称:ProgNET2014,代码行数:29,代码来源:MainWindowModel.cs

示例7: ObserveWindowViewModel

        public ObserveWindowViewModel( string filename, IActorRef tailCoordinator )
        {
            _tailCoordinator = tailCoordinator;
            Filename = filename;
            Title = filename;
            Items = new ReactiveList<String>();

            // start coordinator
            _tailCoordinator.Tell( new TailCoordinatorActor.StartTail( filename, this ) );

            // this is how we can update the viewmodel
            // from the actor.
            Lines = new Subject<String>();
            Lines.ObserveOnDispatcher().Subscribe( item =>
            {
                Items.Add( item );

                if ( Items.Count > 1500 )
                {
                    Items.RemoveAt( 0 );
                }

                SelectedLine = Items.Count - 1;

            } );
        }
开发者ID:njimenez,项目名称:AkkaProjects,代码行数:26,代码来源:ObserveWindowViewModel.cs

示例8: HistoryViewModel

        public HistoryViewModel(IRequestHistory requests)
        {
            Requests = new ReactiveList<HttpRequest>();
            requests.GetRequestsAsync().ContinueWith(continuation => Requests.AddRange(continuation.Result));
            requests.GetRequestsObservable().Subscribe(request => Requests.Add(request));

            SelectedRequestObservable = this.ObservableForProperty(vm => vm.SelectedRequest).Select(r => r.Value);
        }
开发者ID:georgebearden,项目名称:Peticion,代码行数:8,代码来源:HistoryViewModel.cs

示例9: PullRequestDetailViewModelDesigner

        public PullRequestDetailViewModelDesigner()
        {
            var repoPath = @"C:\Repo";

            Model = new PullRequestModel(419, 
                "Error handling/bubbling from viewmodels to views to viewhosts",
                 new AccountDesigner { Login = "shana", IsUser = true },
                 DateTime.Now.Subtract(TimeSpan.FromDays(3)))
            {
                State = PullRequestStateEnum.Open,
                CommitCount = 9,
            };

            SourceBranchDisplayName = "shana/error-handling";
            TargetBranchDisplayName = "master";
            Body = @"Adds a way to surface errors from the view model to the view so that view hosts can get to them.

ViewModels are responsible for handling the UI on the view they control, but they shouldn't be handling UI for things outside of the view. In this case, we're showing errors in VS outside the view, and that should be handled by the section that is hosting the view.

This requires that errors be propagated from the viewmodel to the view and from there to the host via the IView interface, since hosts don't usually know what they're hosting.

![An image](https://cloud.githubusercontent.com/assets/1174461/18882991/5dd35648-8496-11e6-8735-82c3a182e8b4.png)";

            var gitHubDir = new PullRequestDirectoryNode("GitHub");
            var modelsDir = new PullRequestDirectoryNode("Models");
            var repositoriesDir = new PullRequestDirectoryNode("Repositories");
            var itrackingBranch = new PullRequestFileNode(repoPath, @"GitHub\Models\ITrackingBranch.cs", PullRequestFileStatus.Modified);
            var oldBranchModel = new PullRequestFileNode(repoPath, @"GitHub\Models\OldBranchModel.cs", PullRequestFileStatus.Removed);
            var concurrentRepositoryConnection = new PullRequestFileNode(repoPath, @"GitHub\Repositories\ConcurrentRepositoryConnection.cs", PullRequestFileStatus.Added);

            repositoriesDir.Files.Add(concurrentRepositoryConnection);
            modelsDir.Directories.Add(repositoriesDir);
            modelsDir.Files.Add(itrackingBranch);
            modelsDir.Files.Add(oldBranchModel);
            gitHubDir.Directories.Add(modelsDir);

            ChangedFilesTree = new ReactiveList<IPullRequestChangeNode>();
            ChangedFilesTree.Add(gitHubDir);

            ChangedFilesList = new ReactiveList<IPullRequestFileNode>();
            ChangedFilesList.Add(concurrentRepositoryConnection);
            ChangedFilesList.Add(itrackingBranch);
            ChangedFilesList.Add(oldBranchModel);
        }
开发者ID:github,项目名称:VisualStudio,代码行数:44,代码来源:PullRequestDetailViewModelDesigner.cs

示例10: DispatchViewModel

        public DispatchViewModel(IScreen screen, ISession session)
        {
            HostScreen = screen;
            GoBack = HostScreen.Router.NavigateBack;

            Techs = new ReactiveList<Employee>();
            Tickets = new ReactiveList<Ticket>();

            var getFreshTechs = new ReactiveCommand();
            getFreshTechs.ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
                {
                    Techs.Clear();
                    session.FetchResults<Employee>()
                        .ObserveOn(RxApp.MainThreadScheduler)
                        .Subscribe(x => Techs.Add(x));
                });

            var getFreshTickets = new ReactiveCommand();
            getFreshTickets.ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
                {
                    Tickets.Clear();
                    session.FetchResults<Ticket>()
                        .ObserveOn(RxApp.MainThreadScheduler)
                        .Subscribe(x => Tickets.Add(x));
                });

            Refresh = new ReactiveCommand(session.IsWorking.Select(x => !x));
            Refresh.Subscribe(_ =>
                {
                    getFreshTechs.Execute(default(object));
                    getFreshTickets.Execute(default(object));
                });

            Assign = new ReactiveCommand(Observable.CombineLatest(
                this.WhenAny(
                    x => x.SelectedEmployee,
                    y => y.SelectedTicket,
                    (x, y) => x.Value != null && y.Value != null),
                Refresh.CanExecuteObservable,
                (x, y) => x && y));
            Assign.Subscribe(_ =>
            {
                using (session.ScopedChanges())
                {
                    var eventTaker = session.Take<TicketEvent>();
                    eventTaker.Add(new TicketEvent { Employee = SelectedEmployee, Ticket = SelectedTicket, TicketStatus = TicketStatus.Assigned, Time = DateTime.Now });
                }
            });

            _error = session.ThrownExceptions
                .Select(x => x.Message)
                .ObserveOn(RxApp.MainThreadScheduler)
                .ToProperty(this, x => x.Error);

            Refresh.Execute(default(object));
        }
开发者ID:pingortle,项目名称:CompsysTicketingPlayground,代码行数:56,代码来源:DispatchViewModel.cs

示例11: CollectionCountChangedTest

        public void CollectionCountChangedTest()
        {
            var fixture = new ReactiveList<int>();
            var before_output = new List<int>();
            var output = new List<int>();

            fixture.CountChanging.Subscribe(before_output.Add);
            fixture.CountChanged.Subscribe(output.Add);

            fixture.Add(10);
            fixture.Add(20);
            fixture.Add(30);
            fixture.RemoveAt(1);
            fixture.Clear();

            var before_results = new[] { 0, 1, 2, 3, 2 };
            Assert.AreEqual(before_results.Length, before_output.Count);

            var results = new[] { 1, 2, 3, 2, 0 };
            Assert.AreEqual(results.Length, output.Count);
        }
开发者ID:journeyman,项目名称:PodcastReader,代码行数:21,代码来源:FeedViewModelTests.cs

示例12: AssignedTicketsViewModel

        public AssignedTicketsViewModel(IScreen screen, ISession session)
        {
            HostScreen = screen;
            GoBack = HostScreen.Router.NavigateBack;

            Tickets = new ReactiveList<TicketItemViewModel>();
            Employees = new ReactiveList<Employee>();

            _isFetchingTickets = session.IsWorking
                .ToProperty(this, x => x.IsFetchingTickets);

            this.WhenAnyValue(x => x.SelectedEmployee)
                .Where(x => x != null)
                .Subscribe(x =>
                    {
                        Tickets.Clear();

                        session.FetchMergedResults(
                            QueryHelper.QueryOnTicketsAndEvents,
                            QueryHelper.Filter<TicketWithEvent>(z =>
                                (x.Id == int.MinValue || z.EmployeeId == x.Id) &&
                                z.TicketStatus == TicketStatus.Assigned))
                            .ObserveOn(RxApp.MainThreadScheduler)
                            .Select(y => new TicketItemViewModel(y.Description, y.TicketStatus ?? TicketStatus.Open))
                            .Subscribe(y => Tickets.Add(y));
                    });

            SelectedEmployee = new Employee { Name = "All", TicketEvents = null, Id = int.MinValue };
            Employees.Add(SelectedEmployee);

            session.FetchResults<Employee>()
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(x => Employees.Add(x));

            session.ThrownExceptions.Subscribe(x =>
                {
                    Console.WriteLine(x.Message);
                });
        }
开发者ID:pingortle,项目名称:CompsysTicketingPlayground,代码行数:39,代码来源:AssignedTicketsViewModel.cs

示例13: MainWindowViewModel

        public MainWindowViewModel()
        {
            Extension = "*.docx";
            Folders = @"C:\Test\Test Docs";
            Items = new ReactiveList<ResultItem>();

            CountCommand = ReactiveCommand.Create();
            CountCommand.Subscribe(x => DoCount());

            // this is how we can update the viewmodel 
            // from the actor. 
            AddItem = new Subject<ResultItem>();
            AddItem.ObserveOnDispatcher().Subscribe(item => Items.Add(item));

            m_vmActor = AkkaSystem.System.ActorOf(DocumentInspectorSupervisor.GetProps(this), ActorPaths.DocumentInspectorSupervisor.Name);
        }
开发者ID:m-daniloff,项目名称:DocumentInspector,代码行数:16,代码来源:MainWindowViewModel.cs

示例14: MainWindowModel

        public MainWindowModel()
        {
            Tweets = new ReactiveList<TweetViewModel>();

            LoadTweets = ReactiveCommand.CreateAsyncTask(async _ =>
            {
                await Task.Delay(2000);
                foreach (var t in FakeData.GetFakeTweets())
                    Tweets.Add(t);
            });

            var canRemoveTweet = this.WhenAnyValue(vm => vm.Tweets.Count)
                .Select(c => c > 0);

            RemoveTweet = ReactiveCommand.Create(canRemoveTweet);
            RemoveTweet.Subscribe(_ => Tweets.RemoveAt(0));
        }
开发者ID:reactiveui-forks,项目名称:ProgNET2014,代码行数:17,代码来源:MainWindowModel.cs

示例15: MainWindowViewModel

        public MainWindowViewModel()
        {
            Extension = "*.txt";
            // Folders = @"c:\Users\njimenez\Documents\Projects\CSharp\Games\Poker";
            Folders = @"d:\downloads";
            Items = new ReactiveList<ResultItem>();

            CountCommand = ReactiveCommand.Create();
            CountCommand.Subscribe( x => DoCount() );

            // this is how we can update the viewmodel
            // from the actor.
            AddItem = new Subject<ResultItem>();
            AddItem.ObserveOnDispatcher().Subscribe( item => Items.Add( item ) );

            m_vmActor = AkkaSystem.System.ActorOf( WordCounterSupervisor.GetProps( this ), ActorPaths.WordCounterSupervisorActor.Name );
        }
开发者ID:njimenez,项目名称:AkkaProjects,代码行数:17,代码来源:MainWindowViewModel.cs


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