static PullRequestService CreateTarget( IGitClient gitClient = null, IGitService gitService = null, IVSGitExt gitExt = null, IApiClientFactory apiClientFactory = null, IGraphQLClientFactory graphqlFactory = null, IOperatingSystem os = null, IUsageTracker usageTracker = null) { gitClient = gitClient ?? Substitute.For <IGitClient>(); gitService = gitService ?? Substitute.For <IGitService>(); gitExt = gitExt ?? Substitute.For <IVSGitExt>(); apiClientFactory = apiClientFactory ?? Substitute.For <IApiClientFactory>(); graphqlFactory = graphqlFactory ?? Substitute.For <IGraphQLClientFactory>(); os = os ?? Substitute.For <IOperatingSystem>(); usageTracker = usageTracker ?? Substitute.For <IUsageTracker>(); return(new PullRequestService( gitClient, gitService, gitExt, apiClientFactory, graphqlFactory, os, usageTracker)); }
public ApiCostsFilter(IAppLogStore appLogStore, IAppPlansProvider appPlansProvider, IClock clock, IUsageTracker usageTracker) { this.appLogStore = appLogStore; this.appPlansProvider = appPlansProvider; this.clock = clock; this.usageTracker = usageTracker; }
public PullRequestService(IGitClient gitClient, IGitService gitService, IOperatingSystem os, IUsageTracker usageTracker) { this.gitClient = gitClient; this.gitService = gitService; this.os = os; this.usageTracker = usageTracker; }
public GitHubPaneViewModel(IGitHubServiceProvider serviceProvider, ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, IConnectionManager cm, IRepositoryHosts hosts, IUIProvider uiProvider, IVisualStudioBrowser vsBrowser, IUsageTracker usageTracker) : base(serviceProvider, apiFactory, holder) { Guard.ArgumentNotNull(serviceProvider, nameof(serviceProvider)); Guard.ArgumentNotNull(apiFactory, nameof(apiFactory)); Guard.ArgumentNotNull(holder, nameof(holder)); Guard.ArgumentNotNull(cm, nameof(cm)); Guard.ArgumentNotNull(hosts, nameof(hosts)); Guard.ArgumentNotNull(uiProvider, nameof(uiProvider)); Guard.ArgumentNotNull(vsBrowser, nameof(vsBrowser)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); this.connectionManager = cm; this.hosts = hosts; this.uiProvider = uiProvider; this.usageTracker = usageTracker; CancelCommand = ReactiveCommand.Create(); Title = "GitHub"; Message = String.Empty; browser = vsBrowser; this.WhenAnyValue(x => x.Control.DataContext) .OfType <IPanePageViewModel>() .Select(x => x.WhenAnyValue(y => y.Title)) .Switch() .Subscribe(x => Title = x ?? "GitHub"); }
public CachingUsageTracker(IUsageTracker inner, IMemoryCache cache) : base(cache) { Guard.NotNull(inner, nameof(inner)); this.inner = inner; }
static RepositoryCloneViewModel CreateTarget( IOperatingSystem os = null, IConnectionManager connectionManager = null, IRepositoryCloneService service = null, IUsageService usageService = null, IUsageTracker usageTracker = null, IRepositorySelectViewModel gitHubTab = null, IRepositorySelectViewModel enterpriseTab = null, IGitService gitService = null, IRepositoryUrlViewModel urlTab = null, string defaultClonePath = defaultPath) { os = os ?? Substitute.For <IOperatingSystem>(); connectionManager = connectionManager ?? CreateConnectionManager("https://github.com"); service = service ?? CreateRepositoryCloneService(defaultClonePath); usageService = usageService ?? CreateUsageService(); usageTracker = usageTracker ?? Substitute.For <IUsageTracker>(); gitHubTab = gitHubTab ?? CreateSelectViewModel(); enterpriseTab = enterpriseTab ?? CreateSelectViewModel(); gitService = gitService ?? CreateGitService(true, "https://github.com/owner/repo"); urlTab = urlTab ?? CreateRepositoryUrlViewModel(); return(new RepositoryCloneViewModel( os, connectionManager, service, gitService, usageService, usageTracker, gitHubTab, enterpriseTab, urlTab)); }
public GitHubConnectSection(IGitHubServiceProvider serviceProvider, ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, IConnectionManager manager, IPackageSettings packageSettings, IVSServices vsServices, ILocalRepositories localRepositories, IUsageTracker usageTracker, int index) : base(serviceProvider, apiFactory, holder, manager) { Guard.ArgumentNotNull(apiFactory, nameof(apiFactory)); Guard.ArgumentNotNull(holder, nameof(holder)); Guard.ArgumentNotNull(manager, nameof(manager)); Guard.ArgumentNotNull(packageSettings, nameof(packageSettings)); Guard.ArgumentNotNull(vsServices, nameof(vsServices)); Guard.ArgumentNotNull(localRepositories, nameof(localRepositories)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); Title = "GitHub"; IsEnabled = true; IsVisible = false; sectionIndex = index; this.packageSettings = packageSettings; this.vsServices = vsServices; this.localRepositories = localRepositories; this.usageTracker = usageTracker; Clone = ReactiveCommand.CreateFromTask(DoClone); connectionManager.Connections.CollectionChanged += RefreshConnections; PropertyChanged += OnPropertyChange; UpdateConnection(); }
internal UsageTrackingCommand(ICommand command, IUsageTracker usageTracker, Expression <Func <UsageModel.MeasuresModel, int> > counter) { this.command = command; this.usageTracker = usageTracker; this.counter = counter; }
public GistCreationViewModel( IModelServiceFactory modelServiceFactory, ISelectedTextProvider selectedTextProvider, IGistPublishService gistPublishService, INotificationService notificationService, IUsageTracker usageTracker) { Guard.ArgumentNotNull(selectedTextProvider, nameof(selectedTextProvider)); Guard.ArgumentNotNull(gistPublishService, nameof(gistPublishService)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); this.modelServiceFactory = modelServiceFactory; this.gistPublishService = gistPublishService; this.notificationService = notificationService; this.usageTracker = usageTracker; FileName = VisualStudio.Services.GetFileNameFromActiveDocument() ?? Resources.DefaultGistFileName; SelectedText = selectedTextProvider.GetSelectedText(); var canCreateGist = this.WhenAny( x => x.FileName, fileName => !String.IsNullOrEmpty(fileName.Value)); CreateGist = ReactiveCommand.CreateFromObservable(OnCreateGist, canCreateGist); }
public GistCreationViewModel( IRepositoryHost repositoryHost, ISelectedTextProvider selectedTextProvider, IGistPublishService gistPublishService, IUsageTracker usageTracker) { Title = Resources.CreateGistTitle; apiClient = repositoryHost.ApiClient; this.gistPublishService = gistPublishService; this.usageTracker = usageTracker; FileName = VisualStudio.Services.GetFileNameFromActiveDocument() ?? Resources.DefaultGistFileName; SelectedText = selectedTextProvider.GetSelectedText(); // This class is only instantiated after we are logged into to a github account, so we should be safe to grab the first one here as the defaut. account = repositoryHost.ModelService.GetAccounts() .FirstAsync() .Select(a => a.First()) .ObserveOn(RxApp.MainThreadScheduler) .ToProperty(this, vm => vm.Account); var canCreateGist = this.WhenAny( x => x.FileName, fileName => !String.IsNullOrEmpty(fileName.Value)); CreateGist = ReactiveCommand.CreateAsyncObservable(canCreateGist, OnCreateGist); }
public UsageTrackerGrain(IStore <string> store, IUsageTracker usageTracker) : base(store) { Guard.NotNull(usageTracker, nameof(usageTracker)); this.usageTracker = usageTracker; }
public RepositoryForkService(IGitClient gitClient, IVSGitServices vsGitServices, IVSGitExt vsGitExt, IUsageTracker usageTracker) { this.gitClient = gitClient; this.vsGitServices = vsGitServices; this.vsGitExt = vsGitExt; this.usageTracker = usageTracker; }
RepositoryCreationViewModel( IConnectionRepositoryHostMap connectionRepositoryHostMap, IOperatingSystem operatingSystem, IRepositoryCreationService repositoryCreationService, IUsageTracker usageTracker) : this(connectionRepositoryHostMap.CurrentRepositoryHost, operatingSystem, repositoryCreationService, usageTracker) {}
public PullRequestEditorService( IGitHubServiceProvider serviceProvider, IPullRequestService pullRequestService, IVsEditorAdaptersFactoryService vsEditorAdaptersFactory, IStatusBarNotificationService statusBar, IGoToSolutionOrPullRequestFileCommand goToSolutionOrPullRequestFileCommand, IEditorOptionsFactoryService editorOptionsFactoryService, IUsageTracker usageTracker) { Guard.ArgumentNotNull(serviceProvider, nameof(serviceProvider)); Guard.ArgumentNotNull(pullRequestService, nameof(pullRequestService)); Guard.ArgumentNotNull(vsEditorAdaptersFactory, nameof(vsEditorAdaptersFactory)); Guard.ArgumentNotNull(statusBar, nameof(statusBar)); Guard.ArgumentNotNull(goToSolutionOrPullRequestFileCommand, nameof(goToSolutionOrPullRequestFileCommand)); Guard.ArgumentNotNull(goToSolutionOrPullRequestFileCommand, nameof(editorOptionsFactoryService)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); this.serviceProvider = serviceProvider; this.pullRequestService = pullRequestService; this.vsEditorAdaptersFactory = vsEditorAdaptersFactory; this.statusBar = statusBar; this.goToSolutionOrPullRequestFileCommand = goToSolutionOrPullRequestFileCommand; this.editorOptionsFactoryService = editorOptionsFactoryService; this.usageTracker = usageTracker; }
public PullRequestPageViewModel( IViewViewModelFactory factory, IPullRequestService service, IPullRequestSessionManager sessionManager, ITeamExplorerServices teServices, IVisualStudioBrowser visualStudioBrowser, IUsageTracker usageTracker) { Guard.ArgumentNotNull(factory, nameof(factory)); Guard.ArgumentNotNull(service, nameof(service)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser)); Guard.ArgumentNotNull(teServices, nameof(teServices)); this.factory = factory; this.service = service; this.sessionManager = sessionManager; this.teServices = teServices; this.visualStudioBrowser = visualStudioBrowser; this.usageTracker = usageTracker; timeline.ItemsRemoved.Subscribe(TimelineItemRemoved); ShowCommit = ReactiveCommand.CreateFromTask <string>(DoShowCommit); OpenOnGitHub = ReactiveCommand.Create(DoOpenOnGitHub); }
public GitHubPaneViewModel(IGitHubServiceProvider serviceProvider, ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, IConnectionManager cm, IUIProvider uiProvider, IVisualStudioBrowser vsBrowser, IUsageTracker usageTracker) : base(serviceProvider, apiFactory, holder) { Guard.ArgumentNotNull(serviceProvider, nameof(serviceProvider)); Guard.ArgumentNotNull(apiFactory, nameof(apiFactory)); Guard.ArgumentNotNull(holder, nameof(holder)); Guard.ArgumentNotNull(cm, nameof(cm)); Guard.ArgumentNotNull(uiProvider, nameof(uiProvider)); Guard.ArgumentNotNull(vsBrowser, nameof(vsBrowser)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); this.connectionManager = cm; this.uiProvider = uiProvider; this.usageTracker = usageTracker; CancelCommand = ReactiveCommand.Create(); Title = "GitHub"; Message = String.Empty; browser = vsBrowser; this.WhenAnyValue(x => x.Control.DataContext) .Subscribe(x => { var pageViewModel = x as IPanePageViewModel; var searchable = x as ISearchablePanePageViewModel; controlViewModel = x as IViewModel; Title = pageViewModel?.Title ?? "GitHub"; IsSearchEnabled = searchable != null; SearchQuery = searchable?.SearchQuery; }); }
public AppApiFilter(IAppProvider appProvider, IAppPlansProvider appPlanProvider, IUsageTracker usageTracker) { this.appProvider = appProvider; this.appPlanProvider = appPlanProvider; this.usageTracker = usageTracker; }
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 RepositoryCreationViewModel( IModelServiceFactory modelServiceFactory, IOperatingSystem operatingSystem, IRepositoryCreationService repositoryCreationService, IUsageTracker usageTracker) { Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); Guard.ArgumentNotNull(operatingSystem, nameof(operatingSystem)); Guard.ArgumentNotNull(repositoryCreationService, nameof(repositoryCreationService)); Guard.ArgumentNotNull(usageTracker, nameof(usageTracker)); this.modelServiceFactory = modelServiceFactory; this.operatingSystem = operatingSystem; this.repositoryCreationService = repositoryCreationService; this.usageTracker = usageTracker; SelectedGitIgnoreTemplate = GitIgnoreItem.None; SelectedLicense = LicenseItem.None; browseForDirectoryCommand.Subscribe(_ => ShowBrowseForDirectoryDialog()); BaseRepositoryPathValidator = ReactivePropertyValidator.ForObservable(this.WhenAny(x => x.BaseRepositoryPath, x => x.Value)) .IfNullOrEmpty(Resources.RepositoryCreationClonePathEmpty) .IfTrue(x => x.Length > 200, Resources.RepositoryCreationClonePathTooLong) .IfContainsInvalidPathChars(Resources.RepositoryCreationClonePathInvalidCharacters) .IfPathNotRooted(Resources.RepositoryCreationClonePathInvalid); var nonNullRepositoryName = this.WhenAny( x => x.RepositoryName, x => x.BaseRepositoryPath, (x, y) => x.Value) .WhereNotNull(); RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .IfNullOrEmpty(Resources.RepositoryNameValidatorEmpty) .IfTrue(x => x.Length > 100, Resources.RepositoryNameValidatorTooLong) .IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists); SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .Add(repoName => { var parsedReference = GetSafeRepositoryName(repoName); return(parsedReference != repoName ? String.Format(CultureInfo.CurrentCulture, Resources.SafeRepositoryNameWarning, parsedReference) : null); }); this.WhenAny(x => x.BaseRepositoryPathValidator.ValidationResult, x => x.Value) .Subscribe(); CreateRepository = InitializeCreateRepositoryCommand(); canKeepPrivate = CanKeepPrivateObservable.CombineLatest(CreateRepository.IsExecuting, (canKeep, publishing) => canKeep && !publishing) .ToProperty(this, x => x.CanKeepPrivate); isCreating = CreateRepository.IsExecuting .ToProperty(this, x => x.IsCreating); BaseRepositoryPath = repositoryCreationService.DefaultClonePath; }
public RepositoryCloneViewModel( IRepositoryHost repositoryHost, IRepositoryCloneService cloneService, IOperatingSystem operatingSystem, INotificationService notificationService, IUsageTracker usageTracker) { this.repositoryHost = repositoryHost; this.cloneService = cloneService; this.operatingSystem = operatingSystem; this.notificationService = notificationService; this.usageTracker = usageTracker; Title = string.Format(CultureInfo.CurrentCulture, Resources.CloneTitle, repositoryHost.Title); Repositories = new TrackingCollection<IRemoteRepositoryModel>(); repositories.ProcessingDelay = TimeSpan.Zero; repositories.Comparer = OrderedComparer<IRemoteRepositoryModel>.OrderBy(x => x.Owner).ThenBy(x => x.Name).Compare; repositories.Filter = FilterRepository; repositories.NewerComparer = OrderedComparer<IRemoteRepositoryModel>.OrderByDescending(x => x.UpdatedAt).Compare; filterTextIsEnabled = this.WhenAny(x => x.IsLoading, loading => loading.Value || repositories.UnfilteredCount > 0 && !LoadingFailed) .ToProperty(this, x => x.FilterTextIsEnabled); this.WhenAny(x => x.IsLoading, x => x.LoadingFailed, (loading, failed) => !loading.Value && !failed.Value && repositories.UnfilteredCount == 0) .Subscribe(x => NoRepositoriesFound = x); this.WhenAny(x => x.FilterText, x => x.Value) .DistinctUntilChanged(StringComparer.OrdinalIgnoreCase) .Throttle(TimeSpan.FromMilliseconds(100), RxApp.MainThreadScheduler) .Subscribe(_ => repositories.Filter = FilterRepository); var baseRepositoryPath = this.WhenAny( x => x.BaseRepositoryPath, x => x.SelectedRepository, (x, y) => x.Value); BaseRepositoryPathValidator = ReactivePropertyValidator.ForObservable(baseRepositoryPath) .IfNullOrEmpty(Resources.RepositoryCreationClonePathEmpty) .IfTrue(x => x.Length > 200, Resources.RepositoryCreationClonePathTooLong) .IfContainsInvalidPathChars(Resources.RepositoryCreationClonePathInvalidCharacters) .IfPathNotRooted(Resources.RepositoryCreationClonePathInvalid) .IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists); var canCloneObservable = this.WhenAny( x => x.SelectedRepository, x => x.BaseRepositoryPathValidator.ValidationResult.IsValid, (x, y) => x.Value != null && y.Value); canClone = canCloneObservable.ToProperty(this, x => x.CanClone); CloneCommand = ReactiveCommand.CreateAsyncObservable(canCloneObservable, OnCloneRepository); browseForDirectoryCommand.Subscribe(_ => ShowBrowseForDirectoryDialog()); this.WhenAny(x => x.BaseRepositoryPathValidator.ValidationResult, x => x.Value) .Subscribe(); BaseRepositoryPath = cloneService.DefaultClonePath; NoRepositoriesFound = true; }
public CachingUsageTracker(IUsageTracker inner, IMemoryCache cache) { Guard.NotNull(inner, nameof(inner)); Guard.NotNull(cache, nameof(cache)); this.inner = inner; this.cache = cache; }
RepositoryCreationViewModel( IConnectionRepositoryHostMap connectionRepositoryHostMap, IOperatingSystem operatingSystem, IRepositoryCreationService repositoryCreationService, IUsageTracker usageTracker) : this(connectionRepositoryHostMap.CurrentRepositoryHost, operatingSystem, repositoryCreationService, usageTracker) { }
StartPageCloneViewModel( IConnectionRepositoryHostMap connectionRepositoryHostMap, IRepositoryCloneService repositoryCloneService, IOperatingSystem operatingSystem, INotificationService notificationService, IUsageTracker usageTracker) : this(connectionRepositoryHostMap.CurrentRepositoryHost, repositoryCloneService, operatingSystem, notificationService, usageTracker) { }
static GitHubPaneViewModel CreateTarget( IViewViewModelFactory viewModelFactory = null, ISimpleApiClientFactory apiClientFactory = null, IConnectionManager connectionManager = null, ITeamExplorerContext teamExplorerContext = null, IVisualStudioBrowser browser = null, IUsageTracker usageTracker = null, INavigationViewModel navigator = null, ILoggedOutViewModel loggedOut = null, INotAGitHubRepositoryViewModel notAGitHubRepository = null, INotAGitRepositoryViewModel notAGitRepository = null, ILoginFailedViewModel loginFailed = null) { viewModelFactory = viewModelFactory ?? Substitute.For <IViewViewModelFactory>(); connectionManager = connectionManager ?? Substitute.For <IConnectionManager>(); teamExplorerContext = teamExplorerContext ?? CreateTeamExplorerContext(ValidGitHubRepo); browser = browser ?? Substitute.For <IVisualStudioBrowser>(); usageTracker = usageTracker ?? Substitute.For <IUsageTracker>(); loggedOut = loggedOut ?? Substitute.For <ILoggedOutViewModel>(); notAGitHubRepository = notAGitHubRepository ?? Substitute.For <INotAGitHubRepositoryViewModel>(); notAGitRepository = notAGitRepository ?? Substitute.For <INotAGitRepositoryViewModel>(); loginFailed = loginFailed ?? Substitute.For <ILoginFailedViewModel>(); if (navigator == null) { navigator = CreateNavigator(); navigator.Content.Returns((IPanePageViewModel)null); } if (apiClientFactory == null) { var validGitHubRepoClient = Substitute.For <ISimpleApiClient>(); var validEnterpriseRepoClient = Substitute.For <ISimpleApiClient>(); var invalidRepoClient = Substitute.For <ISimpleApiClient>(); validGitHubRepoClient.GetRepository().Returns(new Octokit.Repository(1)); validEnterpriseRepoClient.GetRepository().Returns(new Octokit.Repository(1)); validEnterpriseRepoClient.IsEnterprise().Returns(true); apiClientFactory = Substitute.For <ISimpleApiClientFactory>(); apiClientFactory.Create(null).ReturnsForAnyArgs(invalidRepoClient); apiClientFactory.Create(ValidGitHubRepo).Returns(validGitHubRepoClient); apiClientFactory.Create(ValidEnterpriseRepo).Returns(validEnterpriseRepoClient); } return(new GitHubPaneViewModel( viewModelFactory, apiClientFactory, connectionManager, teamExplorerContext, browser, usageTracker, navigator, loggedOut, notAGitHubRepository, notAGitRepository, loginFailed)); }
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(); }
RepositoryCloneViewModel( IConnectionRepositoryHostMap connectionRepositoryHostMap, IRepositoryCloneService repositoryCloneService, IOperatingSystem operatingSystem, INotificationService notificationService, IUsageTracker usageTracker) : this(connectionRepositoryHostMap.CurrentRepositoryHost, repositoryCloneService, operatingSystem, notificationService, usageTracker) { }
public RepositoryCreationViewModel( IGlobalConnection connection, IModelServiceFactory modelServiceFactory, IOperatingSystem operatingSystem, IRepositoryCreationService repositoryCreationService, IUsageTracker usageTracker) : this(connection.Get(), modelServiceFactory, operatingSystem, repositoryCreationService, usageTracker) { }
public UsageTrackerGrain(IGrainState <GrainState> state, IUsageTracker usageTracker) { Guard.NotNull(state, nameof(state)); Guard.NotNull(usageTracker, nameof(usageTracker)); this.state = state; this.usageTracker = usageTracker; }
public InlineCommentPeekService( IOutliningManagerService outliningManager, IPeekBroker peekBroker, IUsageTracker usageTracker) { this.outliningService = outliningManager; this.peekBroker = peekBroker; this.usageTracker = usageTracker; }
GistCreationViewModel( IConnectionRepositoryHostMap connectionRepositoryHostMap, ISelectedTextProvider selectedTextProvider, IGistPublishService gistPublishService, INotificationService notificationService, IUsageTracker usageTracker) : this(connectionRepositoryHostMap.CurrentRepositoryHost, selectedTextProvider, gistPublishService, usageTracker) { this.notificationService = notificationService; }
public RepositoryCloneService( IOperatingSystem operatingSystem, IVSGitServices vsGitServices, IUsageTracker usageTracker) { this.operatingSystem = operatingSystem; this.vsGitServices = vsGitServices; this.usageTracker = usageTracker; defaultClonePath = GetLocalClonePathFromGitProvider(operatingSystem.Environment.GetUserRepositoriesPath()); }
PullRequestDetailViewModel( IConnectionRepositoryHostMap connectionRepositoryHostMap, ITeamExplorerServiceHolder teservice, IPullRequestService pullRequestsService, IUsageTracker usageTracker) : this(teservice.ActiveRepo, connectionRepositoryHostMap.CurrentRepositoryHost.ModelService, pullRequestsService, usageTracker) { }
public GitHubConnectSection0(IGitHubServiceProvider serviceProvider, ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder, IConnectionManager manager, IPackageSettings settings, ITeamExplorerServices teamExplorerServices, ILocalRepositories localRepositories, IUsageTracker usageTracker) : base(serviceProvider, apiFactory, holder, manager, settings, teamExplorerServices, localRepositories, usageTracker, 0) { }
static RepositoryCloneViewModel GetVM(IRepositoryHost repositoryHost, IRepositoryCloneService cloneService, IOperatingSystem os, INotificationService notificationService, IUsageTracker usageTracker) { var vm = new RepositoryCloneViewModel( repositoryHost, cloneService, os, notificationService, usageTracker); vm.Initialize(null); return vm; }
public RepositoryHostFactory( IApiClientFactory apiClientFactory, IHostCacheFactory hostCacheFactory, ILoginCache loginCache, IAvatarProvider avatarProvider, ITwoFactorChallengeHandler twoFactorChallengeHandler, IUsageTracker usage) { this.apiClientFactory = apiClientFactory; this.hostCacheFactory = hostCacheFactory; this.loginCache = loginCache; this.avatarProvider = avatarProvider; this.twoFactorChallengeHandler = twoFactorChallengeHandler; this.usage = usage; }
public RepositoryHost( IApiClient apiClient, IModelService modelService, ILoginCache loginCache, ITwoFactorChallengeHandler twoFactorChallengeHandler, IUsageTracker usage) { ApiClient = apiClient; ModelService = modelService; this.loginCache = loginCache; this.twoFactorChallengeHandler = twoFactorChallengeHandler; this.usage = usage; Debug.Assert(apiClient.HostAddress != null, "HostAddress of an api client shouldn't be null"); Address = apiClient.HostAddress; hostAddress = apiClient.HostAddress; isEnterprise = !hostAddress.IsGitHubDotCom(); Title = apiClient.HostAddress.Title; }
public StartPageCloneViewModel( IRepositoryHost repositoryHost, IRepositoryCloneService cloneService, IOperatingSystem operatingSystem, INotificationService notificationService, IUsageTracker usageTracker) { this.cloneService = cloneService; this.operatingSystem = operatingSystem; this.notificationService = notificationService; this.usageTracker = usageTracker; Title = string.Format(CultureInfo.CurrentCulture, Resources.CloneTitle, repositoryHost.Title); var baseRepositoryPath = this.WhenAny( x => x.BaseRepositoryPath, x => x.SelectedRepository, (x, y) => x.Value); BaseRepositoryPathValidator = ReactivePropertyValidator.ForObservable(baseRepositoryPath) .IfNullOrEmpty(Resources.RepositoryCreationClonePathEmpty) .IfTrue(x => x.Length > 200, Resources.RepositoryCreationClonePathTooLong) .IfContainsInvalidPathChars(Resources.RepositoryCreationClonePathInvalidCharacters) .IfPathNotRooted(Resources.RepositoryCreationClonePathInvalid) .IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists); var canCloneObservable = this.WhenAny( x => x.SelectedRepository, x => x.BaseRepositoryPathValidator.ValidationResult.IsValid, (x, y) => x.Value != null && y.Value); canClone = canCloneObservable.ToProperty(this, x => x.CanClone); CloneCommand = ReactiveCommand.CreateAsyncObservable(canCloneObservable, OnCloneRepository); browseForDirectoryCommand.Subscribe(_ => ShowBrowseForDirectoryDialog()); this.WhenAny(x => x.BaseRepositoryPathValidator.ValidationResult, x => x.Value) .Subscribe(); BaseRepositoryPath = cloneService.DefaultClonePath; }
public RepositoryCreationViewModel( IRepositoryHost repositoryHost, IOperatingSystem operatingSystem, IRepositoryCreationService repositoryCreationService, IUsageTracker usageTracker) { this.repositoryHost = repositoryHost; this.operatingSystem = operatingSystem; this.repositoryCreationService = repositoryCreationService; this.usageTracker = usageTracker; Title = string.Format(CultureInfo.CurrentCulture, Resources.CreateTitle, repositoryHost.Title); SelectedGitIgnoreTemplate = GitIgnoreItem.None; SelectedLicense = LicenseItem.None; accounts = repositoryHost.ModelService.GetAccounts() .ObserveOn(RxApp.MainThreadScheduler) .ToProperty(this, vm => vm.Accounts, initialValue: new ReadOnlyCollection<IAccount>(new IAccount[] {})); this.WhenAny(x => x.Accounts, x => x.Value) .Select(accts => accts?.FirstOrDefault()) .WhereNotNull() .Subscribe(a => SelectedAccount = a); browseForDirectoryCommand.Subscribe(_ => ShowBrowseForDirectoryDialog()); BaseRepositoryPathValidator = ReactivePropertyValidator.ForObservable(this.WhenAny(x => x.BaseRepositoryPath, x => x.Value)) .IfNullOrEmpty(Resources.RepositoryCreationClonePathEmpty) .IfTrue(x => x.Length > 200, Resources.RepositoryCreationClonePathTooLong) .IfContainsInvalidPathChars(Resources.RepositoryCreationClonePathInvalidCharacters) .IfPathNotRooted(Resources.RepositoryCreationClonePathInvalid); var nonNullRepositoryName = this.WhenAny( x => x.RepositoryName, x => x.BaseRepositoryPath, (x, y) => x.Value) .WhereNotNull(); RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .IfNullOrEmpty(Resources.RepositoryNameValidatorEmpty) .IfTrue(x => x.Length > 100, Resources.RepositoryNameValidatorTooLong) .IfTrue(IsAlreadyRepoAtPath, Resources.RepositoryNameValidatorAlreadyExists); SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .Add(repoName => { var parsedReference = GetSafeRepositoryName(repoName); return parsedReference != repoName ? String.Format(CultureInfo.CurrentCulture, Resources.SafeRepositoryNameWarning, parsedReference) : null; }); this.WhenAny(x => x.BaseRepositoryPathValidator.ValidationResult, x => x.Value) .Subscribe(); CreateRepository = InitializeCreateRepositoryCommand(); canKeepPrivate = CanKeepPrivateObservable.CombineLatest(CreateRepository.IsExecuting, (canKeep, publishing) => canKeep && !publishing) .ToProperty(this, x => x.CanKeepPrivate); isCreating = CreateRepository.IsExecuting .ToProperty(this, x => x.IsCreating); GitIgnoreTemplates = TrackingCollection.CreateListenerCollectionAndRun( repositoryHost.ModelService.GetGitIgnoreTemplates(), new[] { GitIgnoreItem.None }, OrderedComparer<GitIgnoreItem>.OrderByDescending(item => GitIgnoreItem.IsRecommended(item.Name)).Compare, x => { if (x.Name.Equals("VisualStudio", StringComparison.OrdinalIgnoreCase)) SelectedGitIgnoreTemplate = x; }); Licenses = TrackingCollection.CreateListenerCollectionAndRun( repositoryHost.ModelService.GetLicenses(), new[] { LicenseItem.None }, OrderedComparer<LicenseItem>.OrderByDescending(item => LicenseItem.IsRecommended(item.Name)).Compare); BaseRepositoryPath = repositoryCreationService.DefaultClonePath; }
public UsageTrackerDispatcher([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider) { inner = serviceProvider.GetService(typeof(IUsageTracker)) as IUsageTracker; }
public RepositoryPublishViewModel( IRepositoryHosts hosts, IRepositoryPublishService repositoryPublishService, INotificationService notificationService, IConnectionManager connectionManager, IUsageTracker usageTracker) { this.notificationService = notificationService; this.hosts = hosts; this.usageTracker = usageTracker; title = this.WhenAny( x => x.SelectedHost, x => x.Value != null ? string.Format(CultureInfo.CurrentCulture, Resources.PublishToTitle, x.Value.Title) : Resources.PublishTitle ) .ToProperty(this, x => x.Title); Connections = connectionManager.Connections; this.repositoryPublishService = repositoryPublishService; if (Connections.Any()) SelectedConnection = Connections.FirstOrDefault(x => x.HostAddress.IsGitHubDotCom()) ?? Connections[0]; accounts = this.WhenAny(x => x.SelectedConnection, x => x.Value != null ? hosts.LookupHost(x.Value.HostAddress) : RepositoryHosts.DisconnectedRepositoryHost) .Where(x => !(x is DisconnectedRepositoryHost)) .SelectMany(host => host.ModelService.GetAccounts()) .ObserveOn(RxApp.MainThreadScheduler) .ToProperty(this, x => x.Accounts, initialValue: new ReadOnlyCollection<IAccount>(new IAccount[] {})); this.WhenAny(x => x.Accounts, x => x.Value) .WhereNotNull() .Where(accts => accts.Any()) .Subscribe(accts => { var selectedAccount = accts.FirstOrDefault(); if (selectedAccount != null) SelectedAccount = accts.FirstOrDefault(); }); isHostComboBoxVisible = this.WhenAny(x => x.Connections, x => x.Value) .WhereNotNull() .Select(h => h.Count > 1) .ToProperty(this, x => x.IsHostComboBoxVisible); InitializeValidation(); PublishRepository = InitializePublishRepositoryCommand(); canKeepPrivate = CanKeepPrivateObservable.CombineLatest(PublishRepository.IsExecuting, (canKeep, publishing) => canKeep && !publishing) .ToProperty(this, x => x.CanKeepPrivate); isPublishing = PublishRepository.IsExecuting .ToProperty(this, x => x.IsPublishing); var defaultRepositoryName = repositoryPublishService.LocalRepositoryName; if (!string.IsNullOrEmpty(defaultRepositoryName)) RepositoryName = defaultRepositoryName; this.WhenAny(x => x.SelectedConnection, x => x.SelectedAccount, (a,b) => true) .Where(x => RepositoryNameValidator.ValidationResult != null && SafeRepositoryNameWarningValidator.ValidationResult != null) .Subscribe(async _ => { var name = RepositoryName; RepositoryName = null; await RepositoryNameValidator.ResetAsync(); await SafeRepositoryNameWarningValidator.ResetAsync(); RepositoryName = name; }); }