internal static string GetCurrentVsRootHive() { string hive = RecipeManager.GetCurrentVsHive(); if (string.IsNullOrEmpty(hive)) { DefaultRegistryRootAttribute rootAttrib = (DefaultRegistryRootAttribute) Attribute.GetCustomAttribute( typeof(RecipeManagerPackage), typeof(DefaultRegistryRootAttribute)); if (rootAttrib == null) { throw new InvalidOperationException(Properties.Resources.Missing_RegRoot); } return(rootAttrib.Root); } return(RegistryHelper.VisualStudioRoot + hive); }
private Hashtable GetItemsTemplates(Guid projectFactory) { if (!itemTemplatesInFolder.ContainsKey(projectFactory)) { Hashtable templatesInProject = new Hashtable(7); IRecipeManagerService recipeManager = (IRecipeManagerService)GetService(typeof(IRecipeManagerService)); foreach (Configuration.Manifest.GuidancePackage package in recipeManager.GetInstalledPackages("VisualStudio")) { Guid packageGuid = new Guid(package.Guid); string itemTemplateKey = string.Format(CultureInfo.InvariantCulture, ItemTemplatesRegistryPath, projectFactory.ToString("B"), packageGuid.ToString("B")); DefaultRegistryRootAttribute registryRoot = (DefaultRegistryRootAttribute)Attribute.GetCustomAttribute( typeof(RecipeManagerPackage), typeof(DefaultRegistryRootAttribute)); RecipeManagerPackage gaxPackage = (RecipeManagerPackage)GetService(typeof(RecipeManagerPackage)); if (gaxPackage != null) { #if DEBUG Debug.WriteLine(string.Format("Retrieving item templates information from {0}", gaxPackage.ApplicationRegistryRoot.ToString())); #endif using (RegistryKey key = gaxPackage.ApplicationRegistryRoot.OpenSubKey(itemTemplateKey)) { if (key != null) { string templateDir = (string)key.GetValue("TemplatesDir"); templatesInProject.Add(templateDir, packageGuid); } } } } itemTemplatesInFolder.Add(projectFactory, templatesInProject); } return((Hashtable)itemTemplatesInFolder[projectFactory]); }