Ejemplo n.º 1
0
        public VSGitExt(IGitHubServiceProvider serviceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory)
        {
            this.serviceProvider   = serviceProvider;
            this.repositoryFactory = repositoryFactory;

            // The IGitExt service isn't available when a TFS based solution is opened directly.
            // It will become available when moving to a Git based solution (cause a UIContext event to fire).
            context = factory.GetUIContext(new Guid(Guids.GitSccProviderId));

            // Start with empty array until we have a change to initialize.
            ActiveRepositories = Array.Empty <ILocalRepositoryModel>();

            if (context.IsActive && TryInitialize())
            {
                // Refresh ActiveRepositories on background thread so we don't delay startup.
                InitializeTask = Task.Run(() => RefreshActiveRepositories());
            }
            else
            {
                // If we're not in the UIContext or TryInitialize fails, have another go when the UIContext changes.
                context.UIContextChanged += ContextChanged;
                log.Debug("VSGitExt will be initialized later");
                InitializeTask = Task.CompletedTask;
            }
        }
Ejemplo n.º 2
0
    static VSGitExt CreateVSGitExt(IVSUIContext context = null, IGitExt gitExt = null, IAsyncServiceProvider sp = null,
                                   ILocalRepositoryModelFactory repoFactory = null)
    {
        context     = context ?? CreateVSUIContext(true);
        gitExt      = gitExt ?? CreateGitExt();
        sp          = sp ?? Substitute.For <IAsyncServiceProvider>();
        repoFactory = repoFactory ?? Substitute.For <ILocalRepositoryModelFactory>();
        var factory     = Substitute.For <IVSUIContextFactory>();
        var contextGuid = new Guid(Guids.GitSccProviderId);

        factory.GetUIContext(contextGuid).Returns(context);
        sp.GetServiceAsync(typeof(IGitExt)).Returns(gitExt);
        var vsGitExt = new VSGitExt(sp, factory, repoFactory);

        vsGitExt.PendingTasks.Wait();
        return(vsGitExt);
    }
Ejemplo n.º 3
0
    static VSGitExt CreateVSGitExt(IVSUIContext context = null, IGitExt gitExt = null, IAsyncServiceProvider sp = null,
                                   ILocalRepositoryModelFactory repoFactory = null, JoinableTaskContext joinableTaskContext = null)
    {
        context             = context ?? CreateVSUIContext(true);
        gitExt              = gitExt ?? CreateGitExt();
        sp                  = sp ?? Substitute.For <IAsyncServiceProvider>();
        repoFactory         = repoFactory ?? Substitute.For <ILocalRepositoryModelFactory>();
        joinableTaskContext = joinableTaskContext ?? new JoinableTaskContext();
        var factory = Substitute.For <IVSUIContextFactory>();

        factory.GetUIContext(UICONTEXT.RepositoryOpen_guid).Returns(context);
        sp.GetServiceAsync(typeof(IGitExt)).Returns(gitExt);
        var vsGitExt = new VSGitExt(sp, factory, repoFactory, joinableTaskContext);

        vsGitExt.JoinTillEmpty();
        return(vsGitExt);
    }
    static VSGitExt CreateVSGitExt(IVSUIContext context   = null, IGitExt gitExt = null, IServiceProvider sp = null,
                                   IGitService gitService = null, JoinableTaskContext joinableTaskContext = null, string contextGuidString = null)
    {
        context = context ?? CreateVSUIContext(true);
        gitExt  = gitExt ?? CreateGitExt();
        var contextGuid = new Guid(contextGuidString ?? Guids.GitSccProviderId);

        sp                  = sp ?? Substitute.For <IServiceProvider>();
        gitService          = gitService ?? Substitute.For <IGitService>();
        joinableTaskContext = joinableTaskContext ?? new JoinableTaskContext();
        var factory = Substitute.For <IVSUIContextFactory>();

        factory.GetUIContext(contextGuid).Returns(context);
        sp.GetService(typeof(IGitExt)).Returns(gitExt);
        var vsGitExt = new VSGitExt(sp, factory, gitService, joinableTaskContext);

        vsGitExt.JoinTillEmpty();
        return(vsGitExt);
    }