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


C# ReactiveList类代码示例

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


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

示例1: IssueMilestonesViewModel

        public IssueMilestonesViewModel(
            Func<Task<IReadOnlyList<Milestone>>> loadMilestones,
            Func<Task<Milestone>> loadSelectedFunc,
            Func<Milestone, Task> saveFunc)
        {
            var milestones = new ReactiveList<Milestone>();
            Milestones = milestones.CreateDerivedCollection(x => CreateItemViewModel(x));

            this.WhenAnyValue(x => x.Selected)
                .Subscribe(x => {
                    foreach (var a in Milestones)
                        a.IsSelected = a.Number == x?.Number;
                });

            DismissCommand = ReactiveCommand.Create();

            SaveCommand = ReactiveCommand.CreateAsyncTask(_ => {
                DismissCommand.ExecuteIfCan();
                return _selected != _previouslySelected ? saveFunc(_selected) : Task.FromResult(0);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                _previouslySelected = Selected = await loadSelectedFunc();
                milestones.Reset(await loadMilestones());
            });
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:26,代码来源:IssueMilestonesViewModel.cs

示例2: LanguagesViewModel

        public LanguagesViewModel(IJsonSerializationService jsonSerializationService, INetworkActivityService networkActivity)
        {
            var languages = new ReactiveList<LanguageModel>();

            Languages = languages.CreateDerivedCollection(
                x => new LanguageItemViewModel(x.Name, x.Slug), 
                x => x.Name.StartsWith(SearchKeyword ?? string.Empty, StringComparison.OrdinalIgnoreCase), 
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            Languages
                .Changed.Select(_ => Unit.Default)
                .Merge(this.WhenAnyValue(x => x.SelectedLanguage).Select(_ => Unit.Default))
                .Select(_ => SelectedLanguage)
                .Where(x => x != null)
                .Subscribe(x =>
                {
                    foreach (var l in Languages)
                        l.Selected = l.Slug == x.Slug;
                });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                var trendingData = await BlobCache.LocalMachine.DownloadUrl(LanguagesUrl, absoluteExpiration: DateTimeOffset.Now.AddDays(1));
                var langs = jsonSerializationService.Deserialize<List<LanguageModel>>(System.Text.Encoding.UTF8.GetString(trendingData));
                langs.Insert(0, DefaultLanguage);
                languages.Reset(langs);
            });

            LoadCommand.TriggerNetworkActivity(networkActivity);
            LoadCommand.ExecuteIfCan();
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:31,代码来源:LanguagesViewModel.cs

示例3: BaseCommitsViewModel

        protected BaseCommitsViewModel()
	    {
            Title = "Commits";

            var gotoCommitCommand = ReactiveCommand.Create();
            gotoCommitCommand.OfType<CommitItemViewModel>().Subscribe(x =>
            {
                var vm = this.CreateViewModel<CommitViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                vm.Node = x.Commit.Sha;
                NavigateTo(vm);
            });

            var commits = new ReactiveList<CommitItemViewModel>();
            Commits = commits.CreateDerivedCollection(
                x => x, 
                x => x.Description.ContainsKeyword(SearchKeyword) || x.Name.ContainsKeyword(SearchKeyword), 
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                commits.SimpleCollectionLoad(CreateRequest(), 
                    x => new CommitItemViewModel(x, gotoCommitCommand.ExecuteIfCan),
                    x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
	    }
开发者ID:zdd910,项目名称:CodeHub,代码行数:25,代码来源:BaseCommitsViewModel.cs

示例4: LibraryGroupViewModel

        protected LibraryGroupViewModel(string header, string addHeader = null, string icon = null) {
            Header = header;
            AddHeader = addHeader;
            Icon = icon;
            if (!Execute.InDesignMode)
                this.SetCommand(x => x.AddCommand);

            Children = new ReactiveList<IHierarchicalLibraryItem>();
            IsExpanded = true;

            this.WhenAnyValue(x => x.SelectedItemsInternal)
                .Select(x => x == null ? null : x.CreateDerivedCollection(i => (IHierarchicalLibraryItem) i))
                .BindTo(this, x => x.SelectedItems);


            UiHelper.TryOnUiThread(() => {
                Children.EnableCollectionSynchronization(_childrenLock);
                _childrenView =
                    Children.CreateCollectionView(
                        new[] {
                            new SortDescription("SortOrder", ListSortDirection.Ascending),
                            new SortDescription("Model.IsFavorite", ListSortDirection.Descending),
                            new SortDescription("Model.Name", ListSortDirection.Ascending)
                        }, null,
                        null, null, true);
                _itemsView = _childrenView;
            });
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:28,代码来源:LibraryGroupViewModel.cs

示例5: AccountsViewModel

        public AccountsViewModel(IAccountsService accountsService)
        {
            _accountsService = accountsService;
            Accounts = new ReactiveList<IAccount>(accountsService);
            LoginCommand = ReactiveCommand.Create();
            GoToAddAccountCommand = ReactiveCommand.Create();
            DeleteAccountCommand = ReactiveCommand.Create();

            DeleteAccountCommand.OfType<IAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    ActiveAccount = null;
                accountsService.Remove(x);
                Accounts.Remove(x);
            });

            LoginCommand.OfType<IAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    DismissCommand.ExecuteIfCan();
                else
                {
                    ActiveAccount = x;
                    MessageBus.Current.SendMessage(new LogoutMessage());
                    DismissCommand.ExecuteIfCan();
                }
            });

            GoToAddAccountCommand.Subscribe(_ => ShowViewModel(CreateViewModel<IAddAccountViewModel>()));

            this.WhenActivated(d => Accounts.Reset(accountsService));
        }
开发者ID:treejames,项目名称:CodeFramework,代码行数:32,代码来源:AccountsViewModel.cs

示例6: BlogViewModel

        public BlogViewModel(string title, Uri feedAddress, IFeedService feedService = null, IBlobCache cache = null)
        {
            Title = title;
            FeedAddress = feedAddress;
            FeedService = feedService ?? Locator.Current.GetService<IFeedService>();
            Cache = cache ?? Locator.Current.GetService<IBlobCache>();

            Articles = new ReactiveList<ArticleViewModel>();

            Refresh = ReactiveCommand.CreateAsyncObservable(x => GetAndFetchLatestArticles());
            Refresh.Subscribe(articles =>
            {
                // this could be done cleaner, send a PR.
                // Refresh.ToPropertyEx(this, x => x.Articles);

                Articles.Clear();
                Articles.AddRange(articles);
            });

            
            Refresh.ThrownExceptions.Subscribe(thrownException => { this.Log().Error(thrownException); });
            _isLoading = Refresh.IsExecuting.ToProperty(this, x => x.IsLoading);

            // post-condition checks
            Condition.Ensures(FeedAddress).IsNotNull();
            Condition.Ensures(FeedService).IsNotNull();
            Condition.Ensures(Cache).IsNotNull();
        }
开发者ID:moswald,项目名称:rxui-samples,代码行数:28,代码来源:BlogViewModel.cs

示例7: MainVM

        public MainVM()
        {
            var bobbyJoe = new Person("Bobby Joe", new[] { new Pet("Fluffy") });
            var bob = new Person("Bob", new[] { bobbyJoe });
            var littleJoe = new Person("Little Joe");
            var joe = new Person("Joe", new[] { littleJoe });
            Family = new ReactiveList<TreeItem> { bob, joe };

            _addPerson = ReactiveCommand.Create();
            _addPerson.Subscribe(_ =>
            {
                if (SelectedItem == null) return;
                var p = new Person(NewName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _addPet = ReactiveCommand.Create();
            _addPet.Subscribe(_ =>
            {
                if (SelectedItem == null) return;
                var p = new Pet(PetName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _collapse = ReactiveCommand.Create();
            _collapse.Subscribe(_ =>
            {
                SelectedItem?.CollapsePath();
            });
        }
开发者ID:reactiveui-forks,项目名称:ReactiveUI-TreeView,代码行数:32,代码来源:MainVM.cs

示例8: 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

示例9: IssueAssigneeViewModel

        public IssueAssigneeViewModel(
            Func<Task<IReadOnlyList<User>>> loadAssignees,
            Func<Task<User>> loadSelectedFunc,
            Func<User, Task> saveFunc)
        {
            var assignees = new ReactiveList<IssueAssigneeItemViewModel>();
            Assignees = assignees.CreateDerivedCollection(
                x => x,
                filter: x => x.Name.ContainsKeyword(SearchKeyword),
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            this.WhenAnyValue(x => x.Selected)
                .Subscribe(x => {
                    foreach (var a in Assignees)
                        a.IsSelected = string.Equals(a.User.Login, x?.Login);
                });

            DismissCommand = ReactiveCommand.Create();

            SaveCommand = ReactiveCommand.CreateAsyncTask(_ => {
                DismissCommand.ExecuteIfCan();
                return Selected != _previouslySelected ? saveFunc(_selected) : Task.FromResult(0);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                _previouslySelected = Selected = await loadSelectedFunc();
                assignees.Reset((await loadAssignees()).Select(CreateItemViewModel));
            });
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:29,代码来源:IssueAssigneeViewModel.cs

示例10: IssueMilestonesViewModel

        public IssueMilestonesViewModel(IApplicationService applicationService)
        {
            Milestones = new ReactiveList<MilestoneModel>();

            SelectMilestoneCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                var milestone = t as MilestoneModel;
                if (milestone != null)
                    SelectedMilestone = milestone;

                if (SaveOnSelect)
                {
                    try
                    {
                        int? milestoneNumber = null;
                        if (SelectedMilestone != null) milestoneNumber = SelectedMilestone.Number;
                        var updateReq = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId].UpdateMilestone(milestoneNumber);
                        await applicationService.Client.ExecuteAsync(updateReq);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Unable to to save milestone! Please try again.", e);
                    }
                }

                DismissCommand.ExecuteIfCan();
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                Milestones.SimpleCollectionLoad(
                    applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Milestones.GetAll(),
                    t as bool?));
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:33,代码来源:IssueMilestonesViewModel.cs

示例11: CreateCollectionView

 private MultiSelectCollectionView<ShortcutViewModel> CreateCollectionView(ReactiveList<ShortcutViewModel> shortcuts)
 {
     var view = new MultiSelectCollectionView<ShortcutViewModel>(shortcuts);
     view.Filter = ApplyFilter;
     view.SortDescriptions.Add(new SortDescription(nameof(ShortcutViewModel.Name), ListSortDirection.Ascending));
     return view;
 }
开发者ID:gatepoet,项目名称:Deicon.TilesDavis,代码行数:7,代码来源:DetailsViewModel.cs

示例12: IssueLabelsViewModel

        public IssueLabelsViewModel(Func<Task<IReadOnlyList<Label>>> loadLabels)
	    {
            var labels = new ReactiveList<Label>();
            Selected = new ReactiveList<Label>();
            Labels = labels.CreateDerivedCollection(x => 
            {
                var vm = new IssueLabelItemViewModel(x);
                vm.IsSelected = Selected.Any(y => string.Equals(y.Name, x.Name));
//                vm.GoToCommand
//                    .Select(_ => x)
//                    .Where(y => vm.IsSelected)
//                    .Where(y => Selected.All(l => l.Url != y.Url))
//                    .Subscribe(Selected.Add);
//                vm.GoToCommand
//                    .Select(_ => x)
//                    .Where(y => !vm.IsSelected)
//                    .Select(y => Selected.Where(l => l.Url == y.Url).ToArray())
//                    .Subscribe(Selected.RemoveAll);
                return vm;
            });

            SelectLabelsCommand = ReactiveCommand.CreateAsyncTask(t => {
                var selectedLabelsUrl = Selected.Select(x => x.Url).ToArray();
                var prevSelectedLabelsUrl = _previouslySelectedLabels.Select(x => x.Url).ToArray();
                var intersect = selectedLabelsUrl.Intersect(prevSelectedLabelsUrl).ToArray();
                var different = selectedLabelsUrl.Length != prevSelectedLabelsUrl.Length || intersect.Length != selectedLabelsUrl.Length;
                return Task.FromResult(0); //different ? updateIssue(new ReadOnlyCollection<Label>(Selected)) : Task.FromResult(0);
	        });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                labels.Reset(await loadLabels());
            });
	    }
开发者ID:zdd910,项目名称:CodeHub,代码行数:33,代码来源:IssueLabelsViewModel.cs

示例13: ChangesetViewModel

        public ChangesetViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;

            Comments = new ReactiveList<CommentModel>();

            GoToHtmlUrlCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Commit).Select(x => x != null));
            GoToHtmlUrlCommand.Select(x => Commit).Subscribe(GoToUrlCommand.ExecuteIfCan);

            GoToRepositoryCommand = ReactiveCommand.Create();
            GoToRepositoryCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToFileCommand = ReactiveCommand.Create();
            GoToFileCommand.OfType<CommitModel.CommitFileModel>().Subscribe(x =>
            {
                if (x.Patch == null)
                {
                    var vm = CreateViewModel<SourceViewModel>();
                    vm.Branch = Commit.Sha;
                    vm.Username = RepositoryOwner;
                    vm.Repository = RepositoryName;
                    vm.Items = new [] 
                    { 
                        new SourceViewModel.SourceItemModel 
                        {
                            ForceBinary = true,
                            GitUrl = x.BlobUrl,
                            Name = x.Filename,
                            Path = x.Filename,
                            HtmlUrl = x.BlobUrl
                        }
                    };
                    vm.CurrentItemIndex = 0;
                    ShowViewModel(vm);
                }
                else
                {
                    var vm = CreateViewModel<ChangesetDiffViewModel>();
                    vm.Username = RepositoryOwner;
                    vm.Repository = RepositoryName;
                    vm.Branch = Commit.Sha;
                    vm.Filename = x.Filename;
                    ShowViewModel(vm);
                }
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
            {
                var forceCacheInvalidation = t as bool?;
                var t1 = this.RequestModel(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Get(), forceCacheInvalidation, response => Commit = response.Data);
                Comments.SimpleCollectionLoad(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Comments.GetAll(), forceCacheInvalidation).FireAndForget();
                return t1;
            });
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:60,代码来源:ChangesetViewModel.cs

示例14: AppState

 public AppState()
 {
     Articles = new ReactiveList<Article> ();
     ElectionArticles = new ReactiveList<ElectionArticle> ();
     Events = new ReactiveList<Event> ();
     OrganizationMenuItems = new ReactiveList<OrganizationMenuItem> ();
 }
开发者ID:dbeattie71,项目名称:HDP-Mobil,代码行数:7,代码来源:AppState.cs

示例15: 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


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