Exemplo n.º 1
0
        /// <summary>
        /// Gets the folder location where packages have been laid down for the specified extension.
        /// </summary>
        /// <param name="extensionId">The installed extension.</param>
        /// <param name="vsExtensionManager">The VS Extension manager instance.</param>
        /// <param name="throwingErrorHandler">
        /// An error handler that accepts the error message string and then throws
        /// the appropriate exception.
        /// </param>
        /// <returns>The absolute path to the extension's packages folder.</returns>
        internal string GetExtensionRepositoryPath(string extensionId, object vsExtensionManager, Action <string> throwingErrorHandler)
        {
            var    extensionManagerShim = new ExtensionManagerShim(vsExtensionManager, throwingErrorHandler);
            string installPath;

            if (!extensionManagerShim.TryGetExtensionInstallPath(extensionId, out installPath))
            {
                throwingErrorHandler(String.Format(VsResources.PreinstalledPackages_InvalidExtensionId,
                                                   extensionId));
                Debug.Fail("The throwingErrorHandler did not throw");
            }

            return(Path.Combine(installPath, "Packages"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the folder location where packages have been laid down for the specified extension.
        /// </summary>
        /// <param name="extensionId">The installed extension.</param>
        /// <param name="vsExtensionManager">The VS Extension manager instance.</param>
        /// <param name="throwingErrorHandler">An error handler that accepts the error message string and then throws the appropriate exception.</param>
        /// <returns>The absolute path to the extension's packages folder.</returns>
        internal string GetExtensionRepositoryPath(string extensionId, object vsExtensionManager, Action<string> throwingErrorHandler)
        {
            var extensionManagerShim = new ExtensionManagerShim(vsExtensionManager, throwingErrorHandler);
            string installPath;

            if (!extensionManagerShim.TryGetExtensionInstallPath(extensionId, out installPath))
            {
                throwingErrorHandler(String.Format(VsResources.PreinstalledPackages_InvalidExtensionId,
                    extensionId));
                Debug.Fail("The throwingErrorHandler did not throw");
            }

            return Path.Combine(installPath, "Packages");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the folder location where packages have been laid down for the specified extension.
        /// </summary>
        /// <param name="extensionId">The installed extension.</param>
        /// <returns>The absolute path to the extension's packages folder.</returns>
        private string GetExtensionRepositoryPath(string extensionId)
        {
            var    extensionManagerShim = new ExtensionManagerShim(extensionManager: null, errorHandler: _errorHandler);
            string installPath;

            if (!extensionManagerShim.TryGetExtensionInstallPath(extensionId, out installPath))
            {
                var errorMessage = string.Format(VsResources.PreinstalledPackages_InvalidExtensionId, extensionId);
                _errorHandler(errorMessage);

                // The error is fatal, cannot continue
                throw new InvalidOperationException(errorMessage);
            }

            return(Path.Combine(installPath, "Packages"));
        }
Exemplo n.º 4
0
        private string GetExtensionRepositoryPath(XElement packagesElement, object vsExtensionManager)
        {
            string repositoryId = packagesElement.GetOptionalAttributeValue("repositoryId");

            if (repositoryId == null)
            {
                ShowErrorMessage(VsResources.TemplateWizard_MissingExtensionId);
                throw new WizardBackoutException();
            }


            var    extensionManagerShim = new ExtensionManagerShim(vsExtensionManager);
            string installPath;

            if (!extensionManagerShim.TryGetExtensionInstallPath(repositoryId, out installPath))
            {
                ShowErrorMessage(String.Format(VsResources.TemplateWizard_InvalidExtensionId,
                                               repositoryId));
                throw new WizardBackoutException();
            }
            return(Path.Combine(installPath, "Packages"));
        }
Exemplo n.º 5
0
        private string GetExtensionRepositoryPath(XElement packagesElement, object vsExtensionManager)
        {
            string repositoryId = packagesElement.GetOptionalAttributeValue("repositoryId");
            if (repositoryId == null)
            {
                ShowErrorMessage(VsResources.TemplateWizard_MissingExtensionId);
                throw new WizardBackoutException();
            }


            var extensionManagerShim = new ExtensionManagerShim(vsExtensionManager);
            string installPath;
            if (!extensionManagerShim.TryGetExtensionInstallPath(repositoryId, out installPath))
            {
                ShowErrorMessage(String.Format(VsResources.TemplateWizard_InvalidExtensionId,
                    repositoryId));
                throw new WizardBackoutException();
            }
            return Path.Combine(installPath, "Packages");
        }
Exemplo n.º 6
0
        private string GetRepositoryPath(XElement packagesElement, RepositoryType repositoryType, string vsTemplatePath, object vsExtensionManager)
        {
            switch (repositoryType)
            {
                case RepositoryType.Template:
                    return Path.GetDirectoryName(vsTemplatePath);
                case RepositoryType.Extension:
                    string repositoryId = packagesElement.GetOptionalAttributeValue("repositoryId");
                    if (repositoryId == null)
                    {
                        ShowErrorMessage(VsResources.TemplateWizard_MissingExtensionId);
                        throw new WizardBackoutException();
                    }


                    var extensionManagerShim = new ExtensionManagerShim(vsExtensionManager);
                    string installPath;
                    if (!extensionManagerShim.TryGetExtensionInstallPath(repositoryId, out installPath))
                    {
                        ShowErrorMessage(String.Format(VsResources.TemplateWizard_InvalidExtensionId,
                            repositoryId));
                        throw new WizardBackoutException();
                    }
                    return Path.Combine(installPath, "Packages");
            }
            // should not happen
            return null;
        }