public PullRequestFilesViewModel( IPullRequestService service, IPullRequestEditorService editorService) { Guard.ArgumentNotNull(service, nameof(service)); Guard.ArgumentNotNull(editorService, nameof(editorService)); this.service = service; DiffFile = ReactiveCommand.CreateAsyncTask(x => (Task)editorService.OpenDiff(pullRequestSession, ((IPullRequestFileNode)x).RelativePath, "HEAD")); ViewFile = ReactiveCommand.CreateAsyncTask(x => (Task)editorService.OpenFile(pullRequestSession, ((IPullRequestFileNode)x).RelativePath, false)); DiffFileWithWorkingDirectory = ReactiveCommand.CreateAsyncTask( isBranchCheckedOut, x => (Task)editorService.OpenDiff(pullRequestSession, ((IPullRequestFileNode)x).RelativePath)); OpenFileInWorkingDirectory = new NonDeletedFileCommand( isBranchCheckedOut, x => (Task)editorService.OpenFile(pullRequestSession, ((IPullRequestFileNode)x).RelativePath, true)); OpenFirstComment = ReactiveCommand.CreateAsyncTask(async x => { var file = (IPullRequestFileNode)x; var thread = await GetFirstCommentThread(file); if (thread != null) { await editorService.OpenDiff(pullRequestSession, file.RelativePath, thread); } }); }
public PullRequestFilesViewModel( IPullRequestService service, IPullRequestEditorService editorService) { Guard.ArgumentNotNull(service, nameof(service)); Guard.ArgumentNotNull(editorService, nameof(editorService)); this.service = service; DiffFile = ReactiveCommand.CreateFromTask <IPullRequestFileNode>(x => editorService.OpenDiff(pullRequestSession, x.RelativePath, "HEAD")); ViewFile = ReactiveCommand.CreateFromTask <IPullRequestFileNode>(x => editorService.OpenFile(pullRequestSession, x.RelativePath, false)); DiffFileWithWorkingDirectory = ReactiveCommand.CreateFromTask <IPullRequestFileNode>( x => editorService.OpenDiff(pullRequestSession, x.RelativePath), isBranchCheckedOut); OpenFileInWorkingDirectory = ReactiveCommand.CreateFromTask <IPullRequestFileNode>( x => editorService.OpenFile(pullRequestSession, x.RelativePath, true), isBranchCheckedOut); OpenFirstComment = ReactiveCommand.CreateFromTask <IPullRequestFileNode>(async file => { var thread = await GetFirstCommentThread(file); if (thread != null) { await editorService.OpenDiff(pullRequestSession, file.RelativePath, thread); } }); }