Esempio n. 1
0
        public VSItemTemplateDirectory(RegistryKey key, VSTemplateDirectory projectDirectory, VSProjectFactoryProject specialProject) : base()
        {
            var directoryKey = key.ToIndexable();

            if (projectDirectory != null)
            {
                this.Package = projectDirectory.Package;
            }
            else
            {
                this.Package = specialProject.Package;
            }

            this.SubDirectories   = new List <VSTemplateDirectory>();
            this.Guid             = Guid.Parse(directoryKey.SubName);
            this.ProjectDirectory = projectDirectory;
            this.SpecialProject   = specialProject;

            var keys = key.Enumerate();

            if (keys.Count() == 1)
            {
                var subKey = key.Enumerate().First();

                ProcessSubKey(subKey, false);
            }
            else
            {
                foreach (var subKey in keys)
                {
                    ProcessSubKey(subKey, true);
                }
            }
        }
Esempio n. 2
0
        private static void PackageIndexerThread()
        {
            var stopWatch = new Stopwatch();

            RaiseOnIndexingStatus("Package indexer started");
            stopWatch.Start();

            var templateDirsKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0_Config\NewProjectTemplates\TemplateDirs");
            var packagesKey     = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0_Config\Packages");
            var projectsKey     = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0_Config\Projects");
            var servicesKey     = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0_Config\Services");

            VSTemplateDirectory.LoadParentDirectory += (Guid parentGuid, out VSTemplateDirectory parent) =>
            {
                var pseudoFolderKey = Registry.CurrentUser.OpenSubKey(string.Format(@"Software\Microsoft\VisualStudio\10.0_Config\NewProjectTemplates\PseudoFolders\{{{0}}}", parentGuid.ToString()));
                var keyIndexable    = pseudoFolderKey.ToIndexable();
                var packageGuid     = Guid.Parse((string)keyIndexable["Package"]);

                if (projectTemplateDirectories.ContainsKey(parentGuid))
                {
                    parent = projectTemplateDirectories[parentGuid];
                }
                else
                {
                    var packageKey = Registry.CurrentUser.OpenSubKey(string.Format(@"Software\Microsoft\VisualStudio\10.0_Config\Packages\{{{0}}}", packageGuid));
                    var package    = new VSPackage(packageGuid, packageKey);

                    parent = new VSTemplateDirectory(pseudoFolderKey, package, true);

                    projectTemplateDirectories.Add(parent.Guid, parent);
                }
            };

            foreach (var packageKey in packagesKey.Enumerate())
            {
                try
                {
                    var package = new VSPackage(new Guid(packageKey.SubName), packageKey.Key);

                    packages.Add(package.PackageGuid, package);
                }
                catch
                {
                }
            }

            foreach (var dirKey in templateDirsKey.Enumerate())
            {
                var packageKey  = Registry.CurrentUser.OpenSubKey(string.Format(@"Software\Microsoft\VisualStudio\10.0_Config\Packages\{0}", dirKey.SubName));
                var package     = packages[new Guid(dirKey.SubName)];
                var templateDir = new VSTemplateDirectory(dirKey.Key, package);

                package.TemplateDirectory = templateDir;

                projectTemplateDirectories.Add(templateDir.Guid, templateDir);
            }

            VSProjectFactoryProject.LoadPackage += (Guid guid, out VSPackage package) =>
            {
                package = packages[guid];
            };

            VSProjectFactoryProject.LoadDirectory += (Guid guid, out VSTemplateDirectory directory) =>
            {
                if (projectTemplateDirectories.ContainsKey(guid))
                {
                    directory = projectTemplateDirectories[guid];
                }
                else
                {
                    directory = null;
                }
            };

            foreach (var projectKey in projectsKey.Enumerate())
            {
                var project = new VSProjectFactoryProject(new Guid(projectKey.SubName), projectKey.Key);

                factoryProjects.Add(project.ProjectGuid, project);
            }

            foreach (var serviceKey in servicesKey.Enumerate())
            {
                var service = new VSPackageService(new Guid(serviceKey.SubName), serviceKey.Key);

                if (service.PackageGuid != Guid.Empty)
                {
                    service.Package = packages[service.PackageGuid];

                    services.Add(service.ServiceGuid, service);
                }
            }

            packageIndexerEvent.Set();

            stopWatch.Stop();
            RaiseOnIndexingStatus("Package indexer complete in " + stopWatch.Elapsed.Seconds.ToString() + " seconds.");
        }