Пример #1
0
        private readonly List <string> projects;    // projects on which to register

        #endregion

        #region Constructor
        private PropertyPageInfo(CodeToolInfo tool, Guid clsid, Guid pageid, string _category, List <string> _projects)
        {
            this.tool   = tool;
            this.clsid  = clsid;
            this.pageid = pageid;
            category    = _category;
            projects    = _projects;

            // sensitize data from the registry
            if (category == null || category.Length == 0)
            {
                category = commonPropertyPages;
            }
            if (String.Compare(category, "Common", true) == 0 || String.Compare(category, commonPropertyPages, true) == 0)
            {
                category = commonPropertyPages;
            }
            if (String.Compare(category, "Config", true) == 0 || String.Compare(category, configPropertyPages, true) == 0)
            {
                category = configPropertyPages;
            }
            if (projects == null)
            {
                projects = new List <string>();
            }
        }
Пример #2
0
        public static PropertyPageInfo PropertyPageInfoFromRegistry(CodeToolInfo tool, RegistryKey propPagesKey, string propPage)
        {
            Guid propPageId = new Guid(propPage);

            if (propPageId != Guid.Empty)
            {
                RegistryKey propPageKey = propPagesKey.OpenSubKey(propPage, false);
                if (propPageKey != null)
                {
                    string clsid = propPageKey.GetValue("clsid") as String;
                    if (clsid != null)
                    {
                        Guid propPaneClsid = new Guid(clsid);
                        if (propPaneClsid != Guid.Empty)
                        {
                            Common.Trace("Property pane found: " + propPagesKey + "\\" + clsid);

                            string category = propPageKey.GetValue("Category") as String;

                            RegistryKey   projectsKey = propPageKey.OpenSubKey("Projects", false);
                            List <string> projects    = new List <string>();
                            if (projectsKey != null)
                            {
                                foreach (string key in projectsKey.GetValueNames())
                                {
                                    projects.Add(NormalizeProject(key));
                                }
                            }
                            return(new PropertyPageInfo(tool, propPaneClsid, propPageId, category, projects));
                        }
                    }
                }
            }
            return(null);
        }
Пример #3
0
        private TargetInfo(CodeToolInfo tool, string targetName, string fileName, string kind, string _versions, string condition, Dictionary <string, string> properties)
        {
            this.targetName = targetName;
            this.tool       = tool;
            this.fileName   = fileName;
            this.kind       = kind;
            versions        = _versions;
            this.condition  = condition;
            this.properties = properties;

            // sanitize
            if (String.Compare(kind, importAfter, true) == 0)
            {
                this.kind = importAfter;
            }
            if (String.Compare(kind, importBefore, true) == 0)
            {
                this.kind = importBefore;
            }
            if (versions == null)
            {
                versions = "";
            }
            else
            {
                versions = versions.Trim();
            }

            // derived
            prefixComment  = "  <!-- Begin CodeTools: " + tool.ToolName + ": " + targetName + " -->";
            postfixComment = "  <!-- End CodeTools: " + tool.ToolName + ": " + targetName + " -->";
        }
Пример #4
0
        static void Listing(List <string> toolNames, string vsRoot)
        {
            Common.Message("Listing for visual studio " + Path.GetFileName(vsRoot));

            IList <CodeToolInfo> tools = CodeToolInfo.ReadAllFromRegistry(UpdateMode.Normal, vsRoot);

            foreach (CodeToolInfo tool in tools)
            {
                if (toolNames.Count == 0 || toolNames.Contains(tool.ToolName))
                {
                    tool.Show();
                }
            }
        }
Пример #5
0
        public override bool Equals(object obj)
        {
            CodeToolInfo t = obj as CodeToolInfo;

            if (t == null)
            {
                return(false);
            }
            if (vsRoot != t.vsRoot)
            {
                return(false);
            }
            if (toolName != t.toolName)
            {
                return(false);
            }
            if (displayName != t.displayName)
            {
                return(false);
            }
            if (refreshDelay != t.refreshDelay)
            {
                return(false);
            }
            if (propertyPages.Count != t.propertyPages.Count)
            {
                return(false);
            }
            for (int i = 0; i < propertyPages.Count; i++)
            {
                if (!propertyPages[i].Equals(t.propertyPages[i]))
                {
                    return(false);
                }
            }
            if (targets.Count != t.targets.Count)
            {
                return(false);
            }
            for (int i = 0; i < targets.Count; i++)
            {
                if (!targets[i].Equals(t.targets[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #6
0
		readonly List<string> projects; 	// projects on which to register

		#endregion

		#region Constructor
		private PropertyPageInfo(CodeToolInfo tool, Guid clsid, Guid pageid, string _category, List<string> _projects)
		{
			this.tool = tool;
			this.clsid = clsid;
			this.pageid = pageid;
			this.category = _category;
			this.projects = _projects;

			// sensitize data from the registry
			if (category == null || category.Length == 0) category = commonPropertyPages;
			if (String.Compare(category, "Common", true) == 0 || String.Compare(category, commonPropertyPages, true) == 0) {
				category = commonPropertyPages;
			}
			if (String.Compare(category, "Config", true) == 0 || String.Compare(category, configPropertyPages, true) == 0) {
				category = configPropertyPages;
			}
			if (projects == null) projects = new List<string>();
		}
Пример #7
0
        private static CodeToolInfo CodeToolsInfoFromRegistry(string vsRoot, string toolName, RegistryKey toolKey)
        {
            int refreshDelay = defaultRefreshDelay;

            try { refreshDelay = (int)toolKey.GetValue("RefreshDelay", defaultRefreshDelay); }
            catch { }
            string displayName = toolKey.GetValue("DisplayName", toolName) as string;

            CodeToolInfo tool = new CodeToolInfo(vsRoot, toolName, displayName, refreshDelay);

            RegistryKey propPagesKey = toolKey.OpenSubKey("PropertyPages", false);

            if (propPagesKey != null)
            {
                foreach (string propPage in propPagesKey.GetSubKeyNames())
                {
                    PropertyPageInfo pageInfo = PropertyPageInfo.PropertyPageInfoFromRegistry(tool, propPagesKey, propPage);
                    if (pageInfo != null)
                    {
                        tool.propertyPages.Add(pageInfo);
                    }
                }
            }

            RegistryKey targetsKey = toolKey.OpenSubKey("CommonTargets", false);

            if (targetsKey != null)
            {
                foreach (string target in targetsKey.GetSubKeyNames())
                {
                    RegistryKey targetKey = targetsKey.OpenSubKey(target, false);
                    if (targetKey != null)
                    {
                        TargetInfo targetInfo = TargetInfo.ReadFromRegistry(tool, targetKey, target);
                        if (targetInfo != null)
                        {
                            tool.targets.Add(targetInfo);
                        }
                    }
                }
            }

            return(tool);
        }
Пример #8
0
        public static TargetInfo ReadFromRegistry(CodeToolInfo tool, RegistryKey targetKey, string targetName)
        {
            string fileName  = null;
            string kind      = importAfter;
            string condition = "";
            string versions  = "";

            Dictionary <string, string> properties = new Dictionary <string, string>();

            foreach (string name in targetKey.GetValueNames())
            {
                if (String.Compare(name, "TargetsFile", true) == 0)
                {
                    fileName = targetKey.GetValue(name) as string;
                }
                else if (String.Compare(name, "TargetsKind", true) == 0)
                {
                    kind = targetKey.GetValue(name) as string;
                }
                else if (String.Compare(name, "TargetsCondition", true) == 0)
                {
                    condition = targetKey.GetValue(name) as string;
                }
                else if (String.Compare(name, "MSBuildVersions", true) == 0 || String.Compare(name, "MSBuildVersion", true) == 0)
                {
                    versions = targetKey.GetValue(name) as string;
                }
                else if (name != null && name.Length > 0)
                {
                    string val = targetKey.GetValue(name) as string;
                    properties.Add(name, val);
                }
            }

            if (fileName == null)
            {
                return(null);
            }

            return(new TargetInfo(tool, targetName, fileName, kind, versions, condition, properties));
        }
Пример #9
0
        static void Update(UpdateMode updateMode, List <string> toolNames, string vsRoot)
        {
            Common.Message("Update for visual studio " + Path.GetFileName(vsRoot));

            IList <CodeToolInfo> tools = CodeToolInfo.ReadAllFromRegistry(updateMode, vsRoot);

            foreach (CodeToolInfo tool in tools)
            {
                if (toolNames.Count == 0 || toolNames.Contains(tool.ToolName))
                {
                    tool.UnInstall();                     // only runs if necessary
                }
            }
            foreach (CodeToolInfo tool in tools)
            {
                if (toolNames.Count == 0 || toolNames.Contains(tool.ToolName))
                {
                    tool.Install();                     // only runs if necessary
                }
            }
        }
Пример #10
0
        private TargetInfo(CodeToolInfo tool, string targetName, string fileName, string kind, string _versions, string condition, Dictionary<string, string> properties)
        {
            this.targetName = targetName;
            this.tool = tool;
            this.fileName = fileName;
            this.kind = kind;
            versions = _versions;
            this.condition = condition;
            this.properties = properties;

            // sanitize
            if (String.Compare(kind, importAfter, true) == 0) this.kind = importAfter;
            if (String.Compare(kind, importBefore, true) == 0) this.kind = importBefore;
            if (versions == null)
                versions = "";
            else
                versions = versions.Trim();

            // derived
            prefixComment = "  <!-- Begin CodeTools: " + tool.ToolName + ": " + targetName + " -->";
            postfixComment = "  <!-- End CodeTools: " + tool.ToolName + ": " + targetName + " -->";
        }
Пример #11
0
		private static CodeToolInfo CodeToolsInfoFromRegistry(string vsRoot, string toolName, RegistryKey toolKey)
		{
			int refreshDelay = defaultRefreshDelay;
			try { refreshDelay = (int)toolKey.GetValue("RefreshDelay", defaultRefreshDelay); }
			catch { }
			string displayName = toolKey.GetValue("DisplayName", toolName) as string;

			CodeToolInfo tool = new CodeToolInfo(vsRoot, toolName, displayName, refreshDelay);

			RegistryKey propPagesKey = toolKey.OpenSubKey("PropertyPages", false);
			if (propPagesKey != null) {
				foreach (string propPage in propPagesKey.GetSubKeyNames()) {
					PropertyPageInfo pageInfo = PropertyPageInfo.PropertyPageInfoFromRegistry(tool, propPagesKey, propPage);
					if (pageInfo != null) tool.propertyPages.Add(pageInfo);
				}
			}

			RegistryKey targetsKey = toolKey.OpenSubKey("CommonTargets", false);
			if (targetsKey != null) {
				foreach (string target in targetsKey.GetSubKeyNames()) {
					RegistryKey targetKey = targetsKey.OpenSubKey(target, false);
					if (targetKey != null) {
						TargetInfo targetInfo = TargetInfo.ReadFromRegistry(tool, targetKey, target);
						if (targetInfo != null) tool.targets.Add(targetInfo);
					}
				}
			}

			return tool;
		}
Пример #12
0
        public static TargetInfo ReadFromRegistry(CodeToolInfo tool, RegistryKey targetKey, string targetName)
        {
            string fileName = null;
            string kind = importAfter;
            string condition = "";
            string versions = "";

            Dictionary<string, string> properties = new Dictionary<string, string>();
            foreach (string name in targetKey.GetValueNames())
            {
                if (String.Compare(name, "TargetsFile", true) == 0)
                {
                    fileName = targetKey.GetValue(name) as string;
                }
                else if (String.Compare(name, "TargetsKind", true) == 0)
                {
                    kind = targetKey.GetValue(name) as string;
                }
                else if (String.Compare(name, "TargetsCondition", true) == 0)
                {
                    condition = targetKey.GetValue(name) as string;
                }
                else if (String.Compare(name, "MSBuildVersions", true) == 0 || String.Compare(name, "MSBuildVersion", true) == 0)
                {
                    versions = targetKey.GetValue(name) as string;
                }
                else if (name != null && name.Length > 0)
                {
                    string val = targetKey.GetValue(name) as string;
                    properties.Add(name, val);
                }
            }

            if (fileName == null) return null;

            return new TargetInfo(tool, targetName, fileName, kind, versions, condition, properties);
        }
Пример #13
0
        public static IList <CodeToolInfo> ReadAllFromRegistry(UpdateMode mode, string vsRoot)
        {
            List <CodeToolInfo> infos = new List <CodeToolInfo>();

            if (mode != UpdateMode.ForceUnInstall)
            {
                RegistryKey root = Common.GetLocalRegistryRoot(vsRoot, "CodeTools");
                if (root != null)
                {
                    String[] toolKeys = root.GetSubKeyNames();
                    foreach (string toolName in toolKeys)
                    {
                        RegistryKey toolKey = root.OpenSubKey(toolName, false);
                        if (toolKey != null)
                        {
                            CodeToolInfo tool = CodeToolsInfoFromRegistry(vsRoot, toolName, toolKey);
                            if (tool.IsRelevant())
                            {
                                infos.Add(tool);
                            }
                        }
                    }
                }
            }

            if (mode != UpdateMode.ForceInstall)
            {
                RegistryKey installedKey = GetInstalledCodeToolsKey(vsRoot, false);
                if (installedKey != null)
                {
                    foreach (string toolName in installedKey.GetSubKeyNames())
                    {
                        RegistryKey toolKey = installedKey.OpenSubKey(toolName, false);
                        if (toolKey != null)
                        {
                            CodeToolInfo itool = CodeToolsInfoFromRegistry(vsRoot, toolName, toolKey);
                            CodeToolInfo tool  = infos.Find(delegate(CodeToolInfo t) { return(t.toolName == itool.toolName); });
                            if (tool != null)
                            {
                                if (tool.Equals(itool))
                                {
                                    // installed tool == described tool
                                    tool.installMode = InstallMode.Active;
                                }
                                else
                                {
                                    // described tool is updated: uninstall and reinstall
                                    itool.installMode = InstallMode.UnInstall;
                                    tool.installMode  = InstallMode.Install;                                     // is actually the default
                                    infos.Add(itool);
                                }
                            }
                            else if (tool == null)
                            {
                                // described tool is gone: uninstall
                                itool.installMode = InstallMode.UnInstall;
                                infos.Add(itool);
                            }
                        }
                    }
                }
            }

            infos.Reverse();             // reverse the list so uninstalls happen before installs
            return(infos);
        }
Пример #14
0
        public static PropertyPageInfo PropertyPageInfoFromRegistry(CodeToolInfo tool, RegistryKey propPagesKey, string propPage)
        {
            Guid propPageId = new Guid(propPage);
            if (propPageId != Guid.Empty)
            {
                RegistryKey propPageKey = propPagesKey.OpenSubKey(propPage, false);
                if (propPageKey != null)
                {
                    string clsid = propPageKey.GetValue("clsid") as String;
                    if (clsid != null)
                    {
                        Guid propPaneClsid = new Guid(clsid);
                        if (propPaneClsid != Guid.Empty)
                        {
                            Common.Trace("Property pane found: " + propPagesKey + "\\" + clsid);

                            string category = propPageKey.GetValue("Category") as String;

                            RegistryKey projectsKey = propPageKey.OpenSubKey("Projects", false);
                            List<string> projects = new List<string>();
                            if (projectsKey != null)
                            {
                                foreach (string key in projectsKey.GetValueNames())
                                {
                                    projects.Add(NormalizeProject(key));
                                }
                            }
                            return new PropertyPageInfo(tool, propPaneClsid, propPageId, category, projects);
                        }
                    }
                }
            }
            return null;
        }