Ejemplo n.º 1
0
        public UnshelveViewModel(
            [NotNull] string directoryPath,
            [NotNull] GitInfo gitInfo,
            [NotNull] TfsInfo tfsInfo,
            [NotNull] IMessageHub messageHub,
            [NotNull] IGitUtility gitUtility,
            [NotNull] ICmdUtility cmdUtility,
            [NotNull] IGitTfsUtility gitTfsUtility,
            [NotNull] ITfsUtility tfsUtility,
            [NotNull] SynchronizationContext synchronizationContext,
            [NotNull] Func <string, bool, ConfirmationViewModel> confirmationViewModelFactory,
            [NotNull] Func <ConfirmationViewModel, IConfirmationWindow> confirmationWindowFactory,
            [NotNull] ICommandManager commandManager,
            [NotNull] IRateLimiter rateLimiter)
            : base(commandManager)
        {
            _messageHub                   = messageHub ?? throw new ArgumentNullException(nameof(messageHub));
            _gitUtility                   = gitUtility ?? throw new ArgumentNullException(nameof(gitUtility));
            _cmdUtility                   = cmdUtility ?? throw new ArgumentNullException(nameof(cmdUtility));
            _gitTfsUtility                = gitTfsUtility ?? throw new ArgumentNullException(nameof(gitTfsUtility));
            _tfsUtility                   = tfsUtility ?? throw new ArgumentNullException(nameof(tfsUtility));
            _synchronizationContext       = synchronizationContext ?? throw new ArgumentNullException(nameof(synchronizationContext));
            _confirmationViewModelFactory = confirmationViewModelFactory ?? throw new ArgumentNullException(nameof(confirmationViewModelFactory));
            _confirmationWindowFactory    = confirmationWindowFactory ?? throw new ArgumentNullException(nameof(confirmationWindowFactory));
            _rateLimiter                  = rateLimiter ?? throw new ArgumentNullException(nameof(rateLimiter));
            _gitInfo       = gitInfo ?? throw new ArgumentNullException(nameof(gitInfo));
            _tfsInfo       = tfsInfo ?? throw new ArgumentNullException(nameof(tfsInfo));
            _directoryPath = directoryPath ?? throw new ArgumentNullException(nameof(directoryPath));

            UnshelveCommand = AddCommand(Unshelve, () => CanExecute);
            CancelCommand   = AddCommand(Cancel, () => !IsLoading);
            OpenShelvesetInBrowserCommand   = AddCommand(OpenShelvesetInBrowser, () => ShelvesetName != null);
            CopyShelvesetToClipboardCommand = AddCommand(CopyShelvesetToClipboard, () => ShelvesetName != null);

            if (User == null)
            {
                UsersSearchPattern = string.Empty; // sets current user
            }

            _messageHub.Publish(DialogType.Unshelve);
            _subscriptionTokens.Add(messageHub.Subscribe <TaskState>(OnTaskAction));
        }
Ejemplo n.º 2
0
        public PullViewModel(
            [NotNull] string directoryPath,
            [NotNull] IMessageHub messageHub,
            [NotNull] IGitTfsUtility gitTfsUtility,
            [NotNull] ITfsUtility tfsUtility,
            [NotNull] IGitUtility gitUtility,
            [NotNull] TfsInfo tfsInfo,
            [NotNull] ICmdUtility cmdUtility,
            [NotNull] ICommandManager commandManager)
            : base(commandManager)
        {
            _messageHub    = messageHub ?? throw new ArgumentNullException(nameof(messageHub));
            _gitTfsUtility = gitTfsUtility ?? throw new ArgumentNullException(nameof(gitTfsUtility));
            _tfsUtility    = tfsUtility ?? throw new ArgumentNullException(nameof(tfsUtility));
            _gitUtility    = gitUtility ?? throw new ArgumentNullException(nameof(gitUtility));
            _tfsInfo       = tfsInfo ?? throw new ArgumentNullException(nameof(tfsInfo));
            _cmdUtility    = cmdUtility ?? throw new ArgumentNullException(nameof(cmdUtility));

            _directoryPath = directoryPath ?? throw new ArgumentNullException(nameof(directoryPath));
        }
Ejemplo n.º 3
0
        public ShelveViewModel(
            [NotNull] string directoryPath,
            [NotNull] GitInfo gitInfo,
            [NotNull] TfsInfo tfsInfo,
            [NotNull] IMessageHub messageHub,
            [NotNull] IGitUtility gitUtility,
            [NotNull] ICmdUtility cmdUtility,
            [NotNull] IGitTfsUtility gitTfsUtility,
            [NotNull] ITfsUtility tfsUtility,
            [NotNull] SynchronizationContext synchronizationContext,
            [NotNull] Func <string, bool, ConfirmationViewModel> confirmationViewModelFactory,
            [NotNull] Func <ConfirmationViewModel, IConfirmationWindow> confirmationWindowFactory,
            [NotNull] ICommandManager commandManager)
            : base(commandManager)
        {
            _messageHub                   = messageHub ?? throw new ArgumentNullException(nameof(messageHub));
            _gitUtility                   = gitUtility ?? throw new ArgumentNullException(nameof(gitUtility));
            _cmdUtility                   = cmdUtility ?? throw new ArgumentNullException(nameof(cmdUtility));
            _gitTfsUtility                = gitTfsUtility ?? throw new ArgumentNullException(nameof(gitTfsUtility));
            _tfsUtility                   = tfsUtility ?? throw new ArgumentNullException(nameof(tfsUtility));
            _synchronizationContext       = synchronizationContext ?? throw new ArgumentNullException(nameof(synchronizationContext));
            _confirmationViewModelFactory = confirmationViewModelFactory ?? throw new ArgumentNullException(nameof(confirmationViewModelFactory));
            _confirmationWindowFactory    = confirmationWindowFactory ?? throw new ArgumentNullException(nameof(confirmationWindowFactory));
            _gitInfo       = gitInfo ?? throw new ArgumentNullException(nameof(gitInfo));
            _tfsInfo       = tfsInfo ?? throw new ArgumentNullException(nameof(tfsInfo));
            _directoryPath = directoryPath ?? throw new ArgumentNullException(nameof(directoryPath));

            ShelveOrCheckinCommand = AddCommand(ShelveOrCheckin, () => CanExecute);
            CancelCommand          = AddCommand(Cancel, () => !IsLoading);

            IsDirty        = CommitDirty = _gitInfo.IsDirty;
            ShelvesetName  = GetShelvesetName();
            CommitMessage  = _gitInfo.CommitMessage ?? string.Empty;
            CommitMessages = _gitInfo.CommitMessages;
            _messageHub.Publish(DialogType.Shelve);
            _subscriptionTokens.Add(messageHub.Subscribe <TaskState>(OnTaskAction));
        }
Ejemplo n.º 4
0
        public MainViewModel(
            [NotNull] SynchronizationContext synchronizationContext,
            [NotNull] IProcessUtility processUtility,
            [NotNull] IMessageHub messageHub,
            [NotNull] ICmdUtility cmdUtility,
            [NotNull] IGitUtility gitUtility,
            [NotNull] Func <string, GitInfo, TfsInfo, ShelveViewModel> shelveViewModelFactory,
            [NotNull] Func <string, GitInfo, TfsInfo, UnshelveViewModel> unshelveViewModelFactory,
            [NotNull] Func <string, TfsInfo, PullViewModel> pullViewModelFactory,
            [NotNull] IGitTfsUtility gitTfsUtility,
            [NotNull] ITfsUtility tfsUtility,
            [NotNull] ICancellationTokenSourceProvider cancellationTokenSourceProvider,
            [NotNull] Func <string, bool, ConfirmationViewModel> confirmationViewModelFactory,
            [NotNull] Func <ConfirmationViewModel, IConfirmationWindow> confirmationWindowFactory,
            [NotNull] ICommandManager commandManager,
            [NotNull] IRateLimiter rateLimiter)
            : base(commandManager)
        {
            _           = rateLimiter ?? throw new ArgumentNullException(nameof(rateLimiter));
            _tfsUtility = tfsUtility;
            _cancellationTokenSourceProvider = cancellationTokenSourceProvider ?? throw new ArgumentNullException(nameof(cancellationTokenSourceProvider));
            _confirmationViewModelFactory    = confirmationViewModelFactory ?? throw new ArgumentNullException(nameof(confirmationViewModelFactory));
            _confirmationWindowFactory       = confirmationWindowFactory ?? throw new ArgumentNullException(nameof(confirmationWindowFactory));
            _rateLimiter              = rateLimiter;
            _pullViewModelFactory     = pullViewModelFactory ?? throw new ArgumentNullException(nameof(pullViewModelFactory));
            _synchronizationContext   = synchronizationContext ?? throw new ArgumentNullException(nameof(synchronizationContext));
            processUtility            = processUtility ?? throw new ArgumentNullException(nameof(processUtility));
            _messageHub               = messageHub ?? throw new ArgumentNullException(nameof(messageHub));
            _cmdUtility               = cmdUtility ?? throw new ArgumentNullException(nameof(cmdUtility));
            _gitUtility               = gitUtility ?? throw new ArgumentNullException(nameof(gitUtility));
            _gitTfsUtility            = gitTfsUtility ?? throw new ArgumentNullException(nameof(gitTfsUtility));
            _shelveViewModelFactory   = shelveViewModelFactory ?? throw new ArgumentNullException(nameof(shelveViewModelFactory));
            _unshelveViewModelFactory = unshelveViewModelFactory ?? throw new ArgumentNullException(nameof(unshelveViewModelFactory));

            processUtility.ProcessMessageFired += ProcessUtility_ProcessMessageFired;
            processUtility.ProcessErrorFired   += ProcessUtility_ProcessErrorFired;

            ChooseDirectoryCommand          = AddCommand(ChooseDirectoryAsync, () => CanBrowse);
            SetDirectoryCommand             = AddCommand <string>(SetDirectoryAsync, directory => CanBrowse);
            PullCommand                     = AddCommand(GitTfsPull, () => CanExecuteGitTfsAction);
            OpenShelveDialogCommand         = AddCommand(OpenShelveDialogAsync, () => CanExecuteGitTfsAction);
            OpenUnshelveDialogCommand       = AddCommand(OpenUnshelveDialogAsync, () => CanExecuteGitTfsAction);
            WindowClosingCommand            = AddCommand(WindowClosing);
            CancelCommand                   = AddCommand(Cancel, () => CanCancel);
            CopyShelvesetToClipboardCommand = AddCommand(CopyShelvesetToClipboard, () => CreatedShelvesetName != null);
            OpenShelvesetInBrowserCommand   = AddCommand(OpenShelvesetInBrowser, () => _createdShelvesetUrl != null);
            ShowLogsCommand                 = AddCommand(ProcessCommands.ViewLogs);
            _dialog = new CommonOpenFileDialog
            {
                IsFolderPicker   = true,
                InitialDirectory = DirectoryPath
            };
            var savedUsedPaths = Settings.Default.UsedDirectoryPaths;

            UsedPaths = string.IsNullOrEmpty(savedUsedPaths)
                ? new ObservableCollection <string>()
                : new ObservableCollection <string>(savedUsedPaths.Split(UsedPathsSeparator).Select(x => x.Trim()).Where(x => x != string.Empty));
            if (!string.IsNullOrWhiteSpace(Settings.Default.DirectoryPath))
            {
                _ = SetDirectoryAsync(Settings.Default.DirectoryPath);
            }

            _subscriptionTokens.Add(messageHub.Subscribe <Message>(OnNewMessage));
            _subscriptionTokens.Add(messageHub.Subscribe <TaskState>(OnTaskAction));
            _subscriptionTokens.Add(messageHub.Subscribe <CancellationState>(OnCancellationStateChange));
            _subscriptionTokens.Add(messageHub.Subscribe <DialogType>(OnDialogChanged));
            _subscriptionTokens.Add(messageHub.Subscribe <GitInfo>(OnGitInfoChanged));
            _subscriptionTokens.Add(messageHub.Subscribe <TfsInfo>(OnTfsInfoChanged));
            _subscriptionTokens.Add(messageHub.Subscribe <ShelvesetData>(OnShelvesetEvent));
            _fileSystemWatcher = new FileSystemWatcher
            {
                Filter = "HEAD.lock",
                IncludeSubdirectories = true,
                InternalBufferSize    = 64 * 1024
            };
            _fileSystemWatcher.Changed += FileSystemWatcher_Changed;

            Version = GetProgramVersion();
        }