public VdRegKey(ref List <BaseRegKey> allRegistryKeys, RegRoot root, string parentPath, XmlNode keyNode) { mRegistryKeys = allRegistryKeys; Id = keyNode.Name; Root = root; if (String.IsNullOrEmpty(parentPath)) { Path = ElementValue(ref keyNode, "Name"); } else { Path += parentPath + "\\" + ElementValue(ref keyNode, "Name"); } XmlNode regValues = keyNode.SelectSingleNode("Values"); // If there are no <Values then this is only parent of sub-key (so do not add it) if (regValues != null && regValues.HasChildNodes) { Values = new List <RegValue>(regValues.ChildNodes.Count); for (int k = 0; k < regValues.ChildNodes.Count; k++) { XmlNode valNode = regValues.ChildNodes[k]; string name = ElementValue(ref valNode, "Name"); RegValueType type = (RegValueType)int.Parse(ElementValue(ref valNode, "ValueTypes")); string value = ElementValue(ref valNode, "Value"); Values.Add(new RegValue(name, type, value)); } // Add registry key mRegistryKeys.Add(this); } else { // Process sub-keys (without adding parent) XmlNode subKeys = keyNode.SelectSingleNode("Keys"); if (subKeys != null && subKeys.HasChildNodes) { for (int i = 0; i < subKeys.ChildNodes.Count; i++) { XmlNode childNode = subKeys.ChildNodes[i]; VdRegKey regKey = new VdRegKey(ref mRegistryKeys, Root, Path, childNode); } } else { // Add registry key (without Values) mRegistryKeys.Add(this); } } }
private void CreateXmlDataAndParseTree() { // Now simply format the XML Document and load it again mXmlData = FormatXMLData(LoadDataFromXML(mProjectFile + ".xml")); SaveDataToXML(mXmlData, mProjectFile + ".xml"); XmlDocument document = new XmlDocument(); try { // Load the XmlDocument with the xmlData ProgressMessage("Converting project '" + mProjectFile + "' to XML..."); document.LoadXml(mXmlData); // 0. Get Project details ProgressMessage("Getting project details..."); XmlNode projectNode = document.SelectSingleNode("/DeployProject"); ProjectName = ElementValue(ref projectNode, "ProjectName"); ProjectType = VdProduct.GetProjectTypeFromGUID(ElementValue(ref projectNode, "ProjectType"), VdProduct.AtrToBool(ElementValue(ref projectNode, "IsWebType"))); XmlNode releaseNode = document.SelectSingleNode("/DeployProject/Configurations/Release"); Output = ElementValue(ref releaseNode, "OutputFilename"); if (String.IsNullOrEmpty(Output)) { releaseNode = document.SelectSingleNode("/DeployProject/Configurations/Debug"); Output = ElementValue(ref releaseNode, "OutputFilename"); } // 1. Get list of <Folder> ProgressMessage("Creating folders..."); XmlNode documentFolderNode = document.SelectSingleNode("/DeployProject/Deployable/Folder"); if (documentFolderNode != null && documentFolderNode.HasChildNodes) { XmlNodeList foldersList = documentFolderNode.ChildNodes; mFolders = new List <BaseFolder>(foldersList.Count); for (int i = 0; i < foldersList.Count; i++) { VdFolder folder = new VdFolder(foldersList.Item(i), ref mFolders, null); if (!String.IsNullOrEmpty(folder.Id)) { mFolders.Add(folder); // Is this [TARGETDIR] -> remember it if (folder.Path == "[TARGETDIR]") { XmlNode defaultDirNode = foldersList.Item(i).SelectSingleNode("DefaultLocation"); DefaultDir = folder.Atribute(ref defaultDirNode, "value"); } } } } // 2. Get list of <File> ProgressMessage("Creating files..."); XmlNode documentFileNode = document.SelectSingleNode(VdProduct.GetFilesNodeNameFromProjectType(ProjectType)); if (documentFileNode != null && documentFileNode.HasChildNodes) { XmlNodeList filesList = documentFileNode.ChildNodes; mFiles = new List <BaseFile>(filesList.Count); for (int i = 0; i < filesList.Count; i++) { VdFile file = new VdFile(filesList.Item(i)); if (!String.IsNullOrEmpty(file.Id)) { mFiles.Add(file); } } } // 3. Get list of <Registry> ProgressMessage("Creating registry keys..."); XmlNode documentRegistryNode = document.SelectSingleNode("/DeployProject/Deployable/Registry"); if (documentRegistryNode != null && documentRegistryNode.HasChildNodes) { XmlNodeList regKeyList = documentRegistryNode.ChildNodes; mRegistryKeys = new List <BaseRegKey>(regKeyList.Count); for (int i = 0; i < regKeyList.Count; i++) { try { var root = (RegRoot)Enum.Parse(typeof(RegRoot), regKeyList.Item(i).Name); XmlNode keysNode = regKeyList.Item(i).SelectSingleNode("Keys"); for (int j = 0; j < keysNode.ChildNodes.Count; j++) { VdRegKey regKey = new VdRegKey(ref mRegistryKeys, root, string.Empty, keysNode.ChildNodes[j]); } } catch (Exception) { } } } // 4. Get Installer details - different for each ProductType! ProgressMessage("Reading product details..."); XmlNode documentProductNode = document.SelectSingleNode(VdProduct.GetInstallerNodeNameFromProjectType(ProjectType)); mProduct = new VdProduct(documentProductNode); // 5. Get list of <Shortcut> ProgressMessage("Creating shortcuts..."); XmlNode documentShortcutNode = document.SelectSingleNode("/DeployProject/Deployable/Shortcut"); if (documentShortcutNode != null && documentShortcutNode.HasChildNodes) { XmlNodeList shortcutsList = documentShortcutNode.ChildNodes; mShortcuts = new List <BaseShortcut>(shortcutsList.Count); for (int i = 0; i < shortcutsList.Count; i++) { VdShortcut shortcut = new VdShortcut(shortcutsList.Item(i)); if (!String.IsNullOrEmpty(shortcut.Id)) { mShortcuts.Add(shortcut); } } } // 6. Get list of OtherType (e.g. ProjectOutput, ...) ProgressMessage("Reading other files..."); XmlNode projectOutputNode = document.SelectSingleNode("/DeployProject/Deployable/ProjectOutput"); if (projectOutputNode != null && projectOutputNode.HasChildNodes) { XmlNodeList projectOutputList = projectOutputNode.ChildNodes; mOtherTypeObjects = new List <BaseOtherType>(projectOutputList.Count); for (int i = 0; i < projectOutputList.Count; i++) { VdOtherType projectOutput = new VdOtherType(projectOutputList.Item(i), OtherType.ProjectOutput); if (!String.IsNullOrEmpty(projectOutput.Id)) { mOtherTypeObjects.Add(projectOutput); } } } } catch (Exception) { } }