예제 #1
0
        public static void RegisterPrimarySourceControlProvider(RcsType rcsType)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            AppHelper.Output(String.Format("Registering Primary Source Control Provider: {0}", rcsType.ToString()));

            int         hr;
            Guid        packageGuid     = new Guid();
            Guid        sccProviderGuid = new Guid();
            SccProvider providerToLoad  = SccProvider.Unknown;
            bool        enabled         = false;

            switch (rcsType)
            {
            case RcsType.Subversion:
            {
                enabled = RegisterSubversionScc(out packageGuid, out sccProviderGuid, out providerToLoad);
                break;
            }

            case RcsType.Git:
            {
                enabled = RegisterGitScc(out packageGuid, out sccProviderGuid, out providerToLoad);
                break;
            }

            case RcsType.Mercurial:
            {
                enabled = RegisterMercurialScc(out packageGuid, out sccProviderGuid, out providerToLoad);
                break;
            }

            case RcsType.Perforce:
            {
                enabled = RegisterPerforceScc(out packageGuid, out sccProviderGuid, out providerToLoad);
                break;
            }
            }

            AppHelper.Output(String.Format("Provider to Load: {0}, Enabled: {1}", providerToLoad.ToString(), enabled));

            if (!enabled)
            {
                return;
            }

            SccProvider currentSccProvider = GetCurrentSccProvider();

            AppHelper.Output(String.Format("Current Provider: {0}", currentSccProvider.ToString()));

            if (providerToLoad == currentSccProvider)
            {
                return;
            }

            var installed = IsSccPackageInstalled(packageGuid);

            AppHelper.Output(String.Format("Provider {0} installed: {1}", providerToLoad.ToString(), installed));

            if (!installed)
            {
                return;
            }

            hr = _VsRegisterScciProvider.RegisterSourceControlProvider(sccProviderGuid);
            Marshal.ThrowExceptionForHR(hr);

            AppHelper.Output(String.Format("Provider {0} registered (providerGuid: {1})", providerToLoad.ToString(), sccProviderGuid.ToString()));
        }
예제 #2
0
 public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
 {
     //SetSCC(_DTE2.Solution.FullName);
     AppHelper.Output("OnAfterOpenSolution");
     return(VSConstants.S_OK);
 }