コード例 #1
0
ファイル: VSGitExt.cs プロジェクト: kapolb/VisualStudio
        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;
            }
        }
コード例 #2
0
ファイル: VSGitExt.cs プロジェクト: zotovv/VisualStudio
        public VSGitExt(IAsyncServiceProvider asyncServiceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory)
        {
            this.asyncServiceProvider = asyncServiceProvider;
            this.repositoryFactory    = repositoryFactory;

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

            // 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 (and cause a UIContext event to fire).
            var context = factory.GetUIContext(new Guid(Guids.GitSccProviderId));

            context.WhenActivated(() => Initialize());
        }
コード例 #3
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);
    }
コード例 #4
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);
    }
コード例 #5
0
        public VSGitExt(IAsyncServiceProvider asyncServiceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory,
                        JoinableTaskContext joinableTaskContext)
        {
            JoinableTaskCollection             = joinableTaskContext.CreateCollection();
            JoinableTaskCollection.DisplayName = nameof(VSGitExt);
            JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);

            this.asyncServiceProvider = asyncServiceProvider;
            this.repositoryFactory    = repositoryFactory;

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

            // Initialize when we enter the context of a Git repository
            var context = factory.GetUIContext(UICONTEXT.RepositoryOpen_guid);

            context.WhenActivated(() => JoinableTaskFactory.RunAsync(InitializeAsync).Task.Forget(log));
        }
コード例 #6
0
        public VSGitExt(IAsyncServiceProvider asyncServiceProvider, IVSUIContextFactory factory, ILocalRepositoryModelFactory repositoryFactory,
                        JoinableTaskContext joinableTaskContext)
        {
            JoinableTaskCollection             = joinableTaskContext.CreateCollection();
            JoinableTaskCollection.DisplayName = nameof(VSGitExt);
            JoinableTaskFactory = joinableTaskContext.CreateFactory(JoinableTaskCollection);

            this.asyncServiceProvider = asyncServiceProvider;
            this.repositoryFactory    = repositoryFactory;

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

            // 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 (and cause a UIContext event to fire).
            var context = factory.GetUIContext(new Guid(Guids.GitSccProviderId));

            context.WhenActivated(() => JoinableTaskFactory.RunAsync(InitializeAsync).Task.Forget(log));
        }
コード例 #7
0
    static VSGitExt CreateVSGitExt(IVSUIContext context = null, IGitExt gitExt = null, IServiceProvider sp = null,
                                   ILocalRepositoryModelFactory repoFactory = 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>();
        repoFactory         = repoFactory ?? Substitute.For <ILocalRepositoryModelFactory>();
        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, repoFactory, joinableTaskContext);

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