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


C# IReactiveCommand.RegisterAsyncTask方法代码示例

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


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

示例1: IssueMilestonesViewModel

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

            SelectMilestoneCommand = new ReactiveCommand();
            SelectMilestoneCommand.RegisterAsyncTask(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.RegisterAsyncTask(t =>
                Milestones.SimpleCollectionLoad(
                    applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Milestones.GetAll(),
                    t as bool?));
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:34,代码来源:IssueMilestonesViewModel.cs

示例2: IssueAssignedToViewModel

        public IssueAssignedToViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;
            Users = new ReactiveCollection<BasicUserModel>();

            SelectUserCommand = new ReactiveCommand();
            SelectUserCommand.RegisterAsyncTask(async t =>
            {
                var selectedUser = t as BasicUserModel;
                if (selectedUser != null)
                    SelectedUser = selectedUser;

                if (SaveOnSelect)
                {
                    var assignee = SelectedUser != null ? SelectedUser.Login : null;
                    var updateReq = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId].UpdateAssignee(assignee);
                    await _applicationService.Client.ExecuteAsync(updateReq);
                }

                DismissCommand.ExecuteIfCan();
            });

            LoadCommand.RegisterAsyncTask(t => 
                Users.SimpleCollectionLoad(applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetAssignees(), t as bool?));
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:25,代码来源:IssueAssignedToViewModel.cs

示例3: IssueLabelsViewModel

	    public IssueLabelsViewModel(IApplicationService applicationService)
	    {
	        Labels = new ReactiveCollection<LabelModel>();
            SelectedLabels = new ReactiveList<LabelModel>();

            SelectLabelsCommand = new ReactiveCommand();
	        SelectLabelsCommand.RegisterAsyncTask(async t =>
	        {
	            var selectedLabels = t as IEnumerable<LabelModel>;
                if (selectedLabels != null)
	                SelectedLabels.Reset(selectedLabels);

	            //If nothing has changed, dont do anything...
                if (OriginalLabels != null && OriginalLabels.Count() == SelectedLabels.Count() &&
                    OriginalLabels.Intersect(SelectedLabels).Count() == SelectedLabels.Count())
	            {
	                DismissCommand.ExecuteIfCan();
	                return;
	            }

	            if (SaveOnSelect)
	            {
	                try
	                {
                        var labels = (SelectedLabels != null && SelectedLabels.Count > 0) 
                                    ? SelectedLabels.Select(y => y.Name).ToArray() : null;
	                    var updateReq =
	                        applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId]
	                            .UpdateLabels(labels);
                        await applicationService.Client.ExecuteAsync(updateReq);
	                }
	                catch (Exception e)
	                {
	                    throw new Exception("Unable to save labels! Please try again.", e);
	                }
	            }

                DismissCommand.ExecuteIfCan();
	        });

	        LoadCommand.RegisterAsyncTask(t =>
	            Labels.SimpleCollectionLoad(
	                applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Labels.GetAll(),
	                t as bool?));
	    }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:45,代码来源:IssueLabelsViewModel.cs

示例4: IssueModifyViewModel

	    protected IssueModifyViewModel()
	    {
            SaveCommand = new ReactiveCommand();
	        SaveCommand.RegisterAsyncTask(t => Save());

            GoToAssigneeCommand = new ReactiveCommand();
	        GoToAssigneeCommand.Subscribe(_ =>
	        {
	            var vm = CreateViewModel<IssueAssignedToViewModel>();
	            vm.RepositoryOwner = RepositoryOwner;
	            vm.RepositoryName = RepositoryName;
	            vm.SelectedUser = AssignedTo;
	            vm.WhenAnyValue(x => x.SelectedUser).Subscribe(x => AssignedTo = x);
                ShowViewModel(vm);
	        });


            GoToMilestonesCommand = new ReactiveCommand();
            GoToMilestonesCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<IssueMilestonesViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                vm.SelectedMilestone = Milestone;
                vm.WhenAnyValue(x => x.SelectedMilestone).Subscribe(x => Milestone = x);
                ShowViewModel(vm);
            });

            GoToLabelsCommand = new ReactiveCommand();
            GoToLabelsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<IssueLabelsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                vm.SelectedLabels.Reset(Labels);
                vm.OriginalLabels = Labels;
                vm.WhenAnyValue(x => x.SelectedLabels).Subscribe(x => Labels = x.ToArray());
                ShowViewModel(vm);
            });
	    }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:40,代码来源:IssueModifyViewModel.cs

示例5: GistCreateViewModel

        public GistCreateViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;

            SaveCommand = new ReactiveCommand();
            SaveCommand.RegisterAsyncTask(async t =>
            {
                if (_files == null || _files.Count == 0)
                    throw new Exception("You cannot create a Gist without atleast one file! Please correct and try again.");

                var createGist = new GistCreateModel
                {
                    Description = Description,
                    Public = Public,
                    Files = Files.ToDictionary(x => x.Key, x => new GistCreateModel.File { Content = x.Value })
                };

                var newGist = (await _applicationService.Client.ExecuteAsync(_applicationService.Client.AuthenticatedUser.Gists.CreateGist(createGist))).Data;
                CreatedGist = newGist;
                DismissCommand.ExecuteIfCan();
            });
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:22,代码来源:GistCreateViewModel.cs

示例6: RepositoriesExploreViewModel

        public RepositoriesExploreViewModel(IApplicationService applicationService, INetworkActivityService networkActivityService)
        {
            _applicationService = applicationService;
            Repositories = new ReactiveCollection<RepositorySearchModel.RepositoryModel>();

            SearchCommand = new ReactiveCommand(this.WhenAnyValue(x => x.SearchText, x => !string.IsNullOrEmpty(x)));
            SearchCommand.IsExecuting.Skip(1).Subscribe(x => 
            {
                if (x)
                    networkActivityService.PushNetworkActive();
                else
                    networkActivityService.PopNetworkActive();
            });
            SearchCommand.RegisterAsyncTask(async t =>
            {
                try
                {
                    var request = applicationService.Client.Repositories.SearchRepositories(new[] { SearchText }, new string[] { });
                    request.UseCache = false;
                    var response = await applicationService.Client.ExecuteAsync(request);
                    Repositories.Reset(response.Data.Items);
                }
                catch (Exception e)
                {
                    throw new Exception("Unable to search for repositories. Please try again.", e);
                }
            });

            GoToRepositoryCommand = new ReactiveCommand();
            GoToRepositoryCommand.OfType<RepositorySearchModel.RepositoryModel>().Subscribe(x =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = x.Owner.Login;
                vm.RepositoryName = x.Name;
                ShowViewModel(vm);
            });
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:37,代码来源:RepositoriesExploreViewModel.cs

示例7: RepositoryViewModel

        public RepositoryViewModel(IApplicationService applicationService)
        {
            ApplicationService = applicationService;

            ToggleStarCommand = new ReactiveCommand(this.WhenAnyValue(x => x.IsStarred, x => x.HasValue));
            ToggleStarCommand.RegisterAsyncTask(t => ToggleStar());

            ToggleWatchCommand = new ReactiveCommand(this.WhenAnyValue(x => x.IsWatched, x => x.HasValue));
            ToggleWatchCommand.RegisterAsyncTask(t => ToggleWatch());

            GoToOwnerCommand = new ReactiveCommand();
            GoToOwnerCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<ProfileViewModel>();
                vm.Username = RepositoryOwner;
                ShowViewModel(vm);
            });

            PinCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Repository, x => x != null));
            PinCommand.Subscribe(x => PinRepository());

            GoToForkParentCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Repository, x => x != null && x.Fork && x.Parent != null));
            GoToForkParentCommand.Subscribe(x =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = Repository.Parent.Owner.Login;
                vm.RepositoryName = Repository.Parent.Name;
                vm.Repository = Repository.Parent;
                ShowViewModel(vm);
            });

            GoToStargazersCommand = new ReactiveCommand();
            GoToStargazersCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<RepositoryStargazersViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToWatchersCommand = new ReactiveCommand();
            GoToWatchersCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<RepositoryWatchersViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToEventsCommand = new ReactiveCommand();
            GoToEventsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<RepositoryEventsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToIssuesCommand = new ReactiveCommand();
            GoToIssuesCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<IssuesViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToReadmeCommand = new ReactiveCommand();
            GoToReadmeCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<ReadmeViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToCommitsCommand = new ReactiveCommand();
            GoToCommitsCommand.Subscribe(_ =>
            {
                if (Branches != null && Branches.Count == 1)
                {
                    var vm = CreateViewModel<ChangesetsViewModel>();
                    vm.RepositoryOwner = RepositoryOwner;
                    vm.RepositoryName = RepositoryName;
                    ShowViewModel(vm);
                }
                else
                {
                    var vm = CreateViewModel<ChangesetBranchesViewModel>();
                    vm.RepositoryOwner = RepositoryOwner;
                    vm.RepositoryName = RepositoryName;
                    ShowViewModel(vm);
                }
            });

            GoToPullRequestsCommand = new ReactiveCommand();
            GoToPullRequestsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<PullRequestsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
//.........这里部分代码省略.........
开发者ID:GSerjo,项目名称:CodeHub,代码行数:101,代码来源:RepositoryViewModel.cs

示例8: ProfileViewModel

        public ProfileViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;

            ToggleFollowingCommand = new ReactiveCommand(this.WhenAnyValue(x => x.IsFollowing, x => x.HasValue));
            ToggleFollowingCommand.RegisterAsyncTask(t => ToggleFollowing());

            GoToGistsCommand = new ReactiveCommand();
            GoToGistsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserGistsViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToRepositoriesCommand = new ReactiveCommand();
            GoToRepositoriesCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserRepositoriesViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToOrganizationsCommand = new ReactiveCommand();
            GoToOrganizationsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<OrganizationsViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToEventsCommand = new ReactiveCommand();
            GoToEventsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserEventsViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToFollowingCommand = new ReactiveCommand();
            GoToFollowingCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserFollowingsViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            GoToFollowersCommand = new ReactiveCommand();
            GoToFollowersCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<UserFollowersViewModel>();
                vm.Username = Username;
                ShowViewModel(vm);
            });

            LoadCommand.RegisterAsyncTask(t =>
            {
                this.RequestModel(applicationService.Client.AuthenticatedUser.IsFollowing(Username), t as bool?, x => IsFollowing = x.Data).FireAndForget();
                return this.RequestModel(applicationService.Client.Users[Username].Get(), t as bool?, response => User = response.Data);
            });
        }
开发者ID:GSerjo,项目名称:CodeHub,代码行数:61,代码来源:ProfileViewModel.cs

示例9: PullRequestViewModel

        public PullRequestViewModel(IApplicationService applicationService, IMarkdownService markdownService, IShareService shareService)
        {
            _applicationService = applicationService;
            _markdownService = markdownService;

            Comments = new ReactiveCollection<IssueCommentModel>();
            Events = new ReactiveCollection<IssueEventModel>();

            MergeCommand = new ReactiveCommand(this.WhenAnyValue(x => x.PullRequest, x => 
                x != null && x.Merged.HasValue && !x.Merged.Value && x.Mergable.HasValue && x.Mergable.Value));
            MergeCommand.RegisterAsyncTask(async t =>
            {
                try
                {
                    var response = await _applicationService.Client.ExecuteAsync(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests[PullRequestId].Merge());
                    if (!response.Data.Merged)
                        throw new Exception(response.Data.Message);
                    var pullRequest = _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests[PullRequestId].Get();
                    await this.RequestModel(pullRequest, true, r => PullRequest = r.Data);
                }
                catch (Exception e)
                {
                    throw new Exception("Unable to Merge: " + e.Message, e);
                }
            });

            ToggleStateCommand = new ReactiveCommand(this.WhenAnyValue(x => x.PullRequest, x => x != null));
            ToggleStateCommand.RegisterAsyncTask(async t =>
            {
                var close = string.Equals(PullRequest.State, "open", StringComparison.OrdinalIgnoreCase);

                try
                {
                    var data = await _applicationService.Client.ExecuteAsync(
                        _applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests[PullRequestId].UpdateState(close ? "closed" : "open"));
                    PullRequest = data.Data;
                }
                catch (Exception e)
                {
                    throw new Exception("Unable to " + (close ? "close" : "open") + " the item. " + e.Message, e);
                }
            });

            GoToCommitsCommand = new ReactiveCommand();
            GoToCommitsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<PullRequestCommitsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                vm.PullRequestId = PullRequestId;
                ShowViewModel(vm);
            });

            GoToFilesCommand = new ReactiveCommand();
            GoToFilesCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<PullRequestFilesViewModel>();
                vm.Username = RepositoryOwner;
                vm.Repository = RepositoryName;
                vm.PullRequestId = PullRequestId;
                ShowViewModel(vm);
            });

            ShareCommand = new ReactiveCommand(this.WhenAnyValue(x => x.PullRequest, x => x != null && !string.IsNullOrEmpty(x.HtmlUrl)));
            ShareCommand.Subscribe(_ => shareService.ShareUrl(PullRequest.HtmlUrl));

            GoToEditCommand = new ReactiveCommand();
            GoToEditCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<IssueEditViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                vm.Id = PullRequestId;
                vm.Issue = Issue;
                vm.WhenAnyValue(x => x.Issue).Skip(1).Subscribe(x => Issue = x);
                ShowViewModel(vm);
            });

            GoToLabelsCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Issue, x => x != null));
            GoToLabelsCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<IssueLabelsViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                vm.IssueId = PullRequestId;
                vm.SaveOnSelect = true;
                vm.SelectedLabels.Reset(Issue.Labels);
                vm.WhenAnyValue(x => x.Labels).Skip(1).Subscribe(x =>
                {
                    Issue.Labels = x.ToList();
                    this.RaisePropertyChanged("Issue");
                });
                ShowViewModel(vm);
            });

            GoToMilestoneCommand = new ReactiveCommand(this.WhenAnyValue(x => x.Issue, x => x != null));
            GoToMilestoneCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<IssueMilestonesViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
//.........这里部分代码省略.........
开发者ID:GSerjo,项目名称:CodeHub,代码行数:101,代码来源:PullRequestViewModel.cs


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