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


C# ReactiveList.CreateDerivedCollection方法代码示例

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


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

示例1: PullRequestFilesViewModel

        public PullRequestFilesViewModel(IApplicationService applicationService)
        {
            var files = new ReactiveList<CommitModel.CommitFileModel>()
            {
//                GroupFunc = y =>
//                {
//                    var filename = "/" + y.Filename;
//                    return filename.Substring(0, filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
//                }
            };
            Files = files.CreateDerivedCollection(x => x);

            GoToSourceCommand =  ReactiveCommand.Create();
            GoToSourceCommand.OfType<CommitModel.CommitFileModel>().Subscribe(x =>
            {
                var vm = CreateViewModel<SourceViewModel>();
//                vm.Name = x.Filename.Substring(x.Filename.LastIndexOf("/", StringComparison.Ordinal) + 1);
//                vm.Path = x.Filename;
//                vm.GitUrl = x.ContentsUrl;
//                vm.ForceBinary = x.Patch == null;
                ShowViewModel(vm);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                files.SimpleCollectionLoad(
                    applicationService.Client.Users[Username].Repositories[Repository].PullRequests[PullRequestId]
                        .GetFiles(), t as bool?));
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:28,代码来源:PullRequestFilesViewModel.cs

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

示例3: BaseEventsViewModel

        protected BaseEventsViewModel(IApplicationService applicationService)
        {
            ApplicationService = applicationService;
            var events = new ReactiveList<EventModel>();
            Events = events.CreateDerivedCollection(CreateEventTextBlocks);
            ReportRepository = true;

            GoToRepositoryCommand = ReactiveCommand.Create();
            GoToRepositoryCommand.OfType<EventModel.RepoModel>().Subscribe(x =>
            {
                var repoId = new RepositoryIdentifier(x.Name);
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = repoId.Owner;
                vm.RepositoryName = repoId.Name;
                ShowViewModel(vm);
            });

            GoToGistCommand = ReactiveCommand.Create();
            GoToGistCommand.OfType<EventModel.GistEvent>().Subscribe(x =>
            {
                var vm = CreateViewModel<GistViewModel>();
                vm.Id = x.Gist.Id;
                vm.Gist = x.Gist;
                ShowViewModel(vm);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t => 
                this.RequestModel(CreateRequest(0, 100), t as bool?, response =>
                {
                    //this.CreateMore(response, m => { }, events.AddRange);
                    events.Reset(response.Data);
                }));
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:33,代码来源:BaseEventsViewModel.cs

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

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

示例6: ExploreViewModel

        public ExploreViewModel(ISessionService applicationService)
        {
            ShowRepositoryDescription = applicationService.Account.ShowRepositoryDescriptionInList;

            Title = "Explore";

            var gotoRepository = new Action<RepositoryItemViewModel>(x => {
                var vm = this.CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = x.Owner;
                vm.RepositoryName = x.Name;
                NavigateTo(vm);
            });

            var repositories = new ReactiveList<Octokit.Repository>();
            Repositories = repositories.CreateDerivedCollection(x => 
                new RepositoryItemViewModel(x, true, gotoRepository));

            var users = new ReactiveList<Octokit.User>();
            Users = users.CreateDerivedCollection(x => 
                new UserItemViewModel(x.Login, x.AvatarUrl, false, () => {
                    var vm = this.CreateViewModel<UserViewModel>();
                    vm.Init(x.Login);
                    NavigateTo(vm);
                }));

            this.WhenAnyValue(x => x.SearchFilter)
                .DistinctUntilChanged()
                .Subscribe(_ => {
                    SearchText = string.Empty;
                    users.Clear();
                    repositories.Clear();
                });

            var canSearch = this.WhenAnyValue(x => x.SearchText).Select(x => !string.IsNullOrEmpty(x));
            SearchCommand = ReactiveCommand.CreateAsyncTask(canSearch, async t => {
                try
                {
                    users.Clear();
                    repositories.Clear();

                    if (SearchFilter == SearchType.Repositories)
                    {
                        var request = new Octokit.SearchRepositoriesRequest(SearchText);
                        var response = await applicationService.GitHubClient.Search.SearchRepo(request);
                        repositories.Reset(response.Items);
                    }
                    else if (SearchFilter == SearchType.Users)
                    {
                        var request = new Octokit.SearchUsersRequest(SearchText);
                        var response = await applicationService.GitHubClient.Search.SearchUsers(request);
                        users.Reset(response.Items);
                    }
                }
                catch (Exception e)
                {
                    var msg = string.Format("Unable to search for {0}. Please try again.", SearchFilter.Humanize());
                    throw new Exception(msg, e);
                }
            });
        }
开发者ID:zdd910,项目名称:CodeHub,代码行数:60,代码来源:ExploreViewModel.cs

示例7: LanguagesViewModel

        public LanguagesViewModel()
        {
            Title = "Languages";

            var languages = new ReactiveList<Language>();
            Languages = languages.CreateDerivedCollection(
                x => new LanguageItemViewModel(x.Name, x.Slug), 
                filter: 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;
                });

            this.WhenAnyValue(x => x.SelectedLanguage)
                .IsNotNull()
                .Subscribe(_ => Dismiss());

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                var languageRepository = new LanguageRepository();
                var langs = await languageRepository.GetLanguages();
                langs.Insert(0, LanguageRepository.DefaultLanguage);
                languages.Reset(langs);
            });
        }
开发者ID:zdd910,项目名称:CodeHub,代码行数:33,代码来源:LanguagesViewModel.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: 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

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

示例11: IssueLabelsViewModel

        public IssueLabelsViewModel(
            Func<Task<IReadOnlyList<Label>>> loadAllLabelsFunc,
            Func<Task<IReadOnlyList<Label>>> loadSelectedFunc,
            Func<IEnumerable<Label>, Task> saveLabelsFunc)
	    {
            var labels = new ReactiveList<Label>();
            var selected = new ReactiveList<Label>();
            Labels = labels.CreateDerivedCollection(x => 
            {
                var vm = new IssueLabelItemViewModel(x);
                vm.IsSelected = selected.Any(y => y.Url == x.Url);
                return vm;
            });

            SaveCommand = ReactiveCommand.CreateAsyncTask(_ =>
            {
                var currentlySelected = Labels.Where(x => x.IsSelected).ToList();
                var selectedLabelsUrl = currentlySelected.Select(x => x.Label.Url).ToArray();
                var prevSelectedLabelsUrl = selected.Select(x => x.Url).ToArray();
                var intersect = selectedLabelsUrl.Intersect(prevSelectedLabelsUrl).ToArray();
                var different = selectedLabelsUrl.Length != prevSelectedLabelsUrl.Length || intersect.Length != selectedLabelsUrl.Length;
                return different ? saveLabelsFunc(currentlySelected.Select(x => x.Label)) : Task.FromResult(0);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                selected.Clear();
                selected.AddRange((await loadSelectedFunc()) ?? Enumerable.Empty<Label>());
                labels.Reset(await loadAllLabelsFunc());
            });
	    }
开发者ID:runt18,项目名称:CodeHub,代码行数:30,代码来源:IssueLabelsViewModel.cs

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

示例13: BaseRepositoriesViewModel

        protected BaseRepositoriesViewModel(ISessionService applicationService)
        {
            ApplicationService = applicationService;
            ShowRepositoryOwner = true;
            Title = "Repositories";

            var gotoRepository = new Action<RepositoryItemViewModel>(x => {
                var vm = this.CreateViewModel<RepositoryViewModel>();
                vm.Init(x.Owner, x.Name);
                NavigateTo(vm);
            });

            var repositories = new ReactiveList<RepositoryItemViewModel>();
            Repositories = repositories.CreateDerivedCollection(
                x => x, 
                filter: x => x.Name.ContainsKeyword(SearchKeyword),
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            //Filter = applicationService.Account.Filters.GetFilter<RepositoriesFilterModel>(filterKey);

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                repositories.SimpleCollectionLoad(CreateRequest(),
                    x => new RepositoryItemViewModel(x.Name, x.Owner.Login, x.Owner.AvatarUrl, 
                        ShowRepositoryDescription ? x.Description : string.Empty, x.StargazersCount, x.ForksCount, 
                        ShowRepositoryOwner, gotoRepository),
                    x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));

//			_repositories.FilteringFunction = x => Repositories.Filter.Ascending ? x.OrderBy(y => y.Name) : x.OrderByDescending(y => y.Name);
//            _repositories.GroupingFunction = CreateGroupedItems;
        }
开发者ID:hoku85,项目名称:CodeHub,代码行数:30,代码来源:BaseRepositoriesViewModel.cs

示例14: BaseUsersViewModel

        protected BaseUsersViewModel()
        {
            var users = new ReactiveList<BasicUserModel>();
            Users = users.CreateDerivedCollection(x => {
                var isOrg = string.Equals(x.Type, "organization", StringComparison.OrdinalIgnoreCase);
                return new UserItemViewModel(x.Login, x.AvatarUrl, isOrg, () => {
                    if (isOrg)
                    {
                        var vm = this.CreateViewModel<OrganizationViewModel>();
                        vm.Init(x.Login);
                        NavigateTo(vm);
                    }
                    else
                    {
                        var vm = this.CreateViewModel<UserViewModel>();
                        vm.Init(x.Login);
                        NavigateTo(vm);
                    }
                });
            },
            x => x.Login.StartsWith(SearchKeyword ?? string.Empty, StringComparison.OrdinalIgnoreCase),
            signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                users.SimpleCollectionLoad(CreateRequest(), 
                x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
        }
开发者ID:zdd910,项目名称:CodeHub,代码行数:27,代码来源:BaseUsersViewModel.cs

示例15: ReleasesViewModel

        public ReleasesViewModel(ISessionService applicationService)
        {
            Title = "Releases";

            var releases = new ReactiveList<Octokit.Release>();
            Releases = releases.CreateDerivedCollection(CreateItemViewModel, x => !x.Draft);

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ =>
                releases.Reset(await applicationService.GitHubClient.Release.GetAll(RepositoryOwner, RepositoryName)));
        }
开发者ID:zdd910,项目名称:CodeHub,代码行数:10,代码来源:ReleasesViewModel.cs


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