Пример #1
0
        public PullRequestDetailViewModel(
            IPullRequestService pullRequestsService,
            IPullRequestSessionManager sessionManager,
            IModelServiceFactory modelServiceFactory,
            IUsageTracker usageTracker,
            ITeamExplorerContext teamExplorerContext,
            IPullRequestFilesViewModel files,
            ISyncSubmodulesCommand syncSubmodulesCommand,
            IViewViewModelFactory viewViewModelFactory)
        {
            Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService));
            Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
            Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
            Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
            Guard.ArgumentNotNull(teamExplorerContext, nameof(teamExplorerContext));
            Guard.ArgumentNotNull(syncSubmodulesCommand, nameof(syncSubmodulesCommand));
            Guard.ArgumentNotNull(viewViewModelFactory, nameof(viewViewModelFactory));

            this.pullRequestsService   = pullRequestsService;
            this.sessionManager        = sessionManager;
            this.modelServiceFactory   = modelServiceFactory;
            this.usageTracker          = usageTracker;
            this.teamExplorerContext   = teamExplorerContext;
            this.syncSubmodulesCommand = syncSubmodulesCommand;
            this.viewViewModelFactory  = viewViewModelFactory;
            Files = files;

            Checkout = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.CheckoutState)
                .Cast <CheckoutCommandState>()
                .Select(x => x != null && x.IsEnabled),
                DoCheckout);
            Checkout.IsExecuting.Subscribe(x => isInCheckout = x);
            SubscribeOperationError(Checkout);

            Pull = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PullEnabled),
                DoPull);
            SubscribeOperationError(Pull);

            Push = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PushEnabled),
                DoPush);
            SubscribeOperationError(Push);

            SyncSubmodules = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.SyncSubmodulesEnabled),
                DoSyncSubmodules);
            SyncSubmodules.Subscribe(_ => Refresh().ToObservable());
            SubscribeOperationError(SyncSubmodules);

            OpenOnGitHub = ReactiveCommand.Create();
            ShowReview   = ReactiveCommand.Create().OnExecuteCompleted(DoShowReview);
        }
        public PullRequestDetailViewModel(
            IPullRequestService pullRequestsService,
            IPullRequestSessionManager sessionManager,
            IModelServiceFactory modelServiceFactory,
            IUsageTracker usageTracker,
            ITeamExplorerContext teamExplorerContext,
            IStatusBarNotificationService statusBarNotificationService)
        {
            Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService));
            Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
            Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
            Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
            Guard.ArgumentNotNull(teamExplorerContext, nameof(teamExplorerContext));
            Guard.ArgumentNotNull(statusBarNotificationService, nameof(statusBarNotificationService));

            this.pullRequestsService          = pullRequestsService;
            this.sessionManager               = sessionManager;
            this.modelServiceFactory          = modelServiceFactory;
            this.usageTracker                 = usageTracker;
            this.teamExplorerContext          = teamExplorerContext;
            this.statusBarNotificationService = statusBarNotificationService;

            Checkout = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.CheckoutState)
                .Cast <CheckoutCommandState>()
                .Select(x => x != null && x.IsEnabled),
                DoCheckout);
            Checkout.IsExecuting.Subscribe(x => isInCheckout = x);
            SubscribeOperationError(Checkout);

            Pull = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PullEnabled),
                DoPull);
            SubscribeOperationError(Pull);

            Push = ReactiveCommand.CreateAsyncObservable(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PushEnabled),
                DoPush);
            SubscribeOperationError(Push);

            SyncSubmodules = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.SyncSubmodulesEnabled),
                DoSyncSubmodules);
            SyncSubmodules.Subscribe(_ => Refresh().ToObservable());
            SubscribeOperationError(SyncSubmodules);

            OpenOnGitHub = ReactiveCommand.Create();
            DiffFile     = ReactiveCommand.Create();
            DiffFileWithWorkingDirectory = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut));
            OpenFileInWorkingDirectory   = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut));
            ViewFile = ReactiveCommand.Create();
        }
Пример #3
0
        public PullRequestDetailViewModel(
            IPullRequestService pullRequestsService,
            IPullRequestSessionManager sessionManager,
            IModelServiceFactory modelServiceFactory,
            IUsageTracker usageTracker,
            ITeamExplorerContext teamExplorerContext,
            IPullRequestFilesViewModel files,
            ISyncSubmodulesCommand syncSubmodulesCommand,
            IViewViewModelFactory viewViewModelFactory,
            IGitService gitService,
            IOpenIssueishDocumentCommand openDocumentCommand,
            [Import(AllowDefault = true)] JoinableTaskContext joinableTaskContext)
        {
            Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService));
            Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
            Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
            Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
            Guard.ArgumentNotNull(teamExplorerContext, nameof(teamExplorerContext));
            Guard.ArgumentNotNull(syncSubmodulesCommand, nameof(syncSubmodulesCommand));
            Guard.ArgumentNotNull(viewViewModelFactory, nameof(viewViewModelFactory));
            Guard.ArgumentNotNull(gitService, nameof(gitService));
            Guard.ArgumentNotNull(openDocumentCommand, nameof(openDocumentCommand));

            this.pullRequestsService   = pullRequestsService;
            this.sessionManager        = sessionManager;
            this.modelServiceFactory   = modelServiceFactory;
            this.usageTracker          = usageTracker;
            this.teamExplorerContext   = teamExplorerContext;
            this.syncSubmodulesCommand = syncSubmodulesCommand;
            this.viewViewModelFactory  = viewViewModelFactory;
            this.gitService            = gitService;
            this.openDocumentCommand   = openDocumentCommand;
            JoinableTaskContext        = joinableTaskContext ?? ThreadHelper.JoinableTaskContext;

            Files = files;

            Checkout = ReactiveCommand.CreateFromObservable(
                DoCheckout,
                this.WhenAnyValue(x => x.CheckoutState)
                .Cast <CheckoutCommandState>()
                .Select(x => x != null && x.IsEnabled));
            Checkout.IsExecuting.Subscribe(x => isInCheckout = x);
            SubscribeOperationError(Checkout);

            Pull = ReactiveCommand.CreateFromObservable(
                DoPull,
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PullEnabled));
            SubscribeOperationError(Pull);

            Push = ReactiveCommand.CreateFromObservable(
                DoPush,
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.PushEnabled));
            SubscribeOperationError(Push);

            SyncSubmodules = ReactiveCommand.CreateFromTask(
                DoSyncSubmodules,
                this.WhenAnyValue(x => x.UpdateState)
                .Cast <UpdateCommandState>()
                .Select(x => x != null && x.SyncSubmodulesEnabled));
            SyncSubmodules.Subscribe(_ => Refresh().ToObservable());
            SubscribeOperationError(SyncSubmodules);

            OpenConversation = ReactiveCommand.Create(DoOpenConversation);

            OpenOnGitHub = ReactiveCommand.Create(DoOpenDetailsUrl);

            ShowReview = ReactiveCommand.Create <IPullRequestReviewSummaryViewModel>(DoShowReview);

            ShowAnnotations = ReactiveCommand.Create <IPullRequestCheckViewModel>(DoShowAnnotations);
        }