Example #1
0
 public VdOtherType(XmlNode otherNode, OtherType type)
 {
     Id         = otherNode.Name;
     Type       = type;
     SourceName = AtributeValue(ref otherNode, "SourcePath");
     if (Type == OtherType.ProjectOutput)
     {
         // Real DestName should be parsed from .csproj file which is really difficult
         // Instead simply keep only file name (without path)
         DestName = AtributeValue(ref otherNode, "TargetName");
         if (String.IsNullOrEmpty(DestName))
         {
             int iPos = SourceName.LastIndexOf('\\');
             if (iPos > 0)
             {
                 DestName = SourceName.Substring(iPos + 1);
             }
             else
             {
                 DestName = SourceName;
             }
         }
     }
     else
     {
         DestName = AtributeValue(ref otherNode, "TargetName");
     }
     FolderId = AtributeValue(ref otherNode, "Folder");
     Exclude  = VdProduct.AtrToBool(AtributeValue(ref otherNode, "Exclude"));
 }
Example #2
0
 public VdShortcut(XmlNode shortcutNode)
 {
     Id          = shortcutNode.Name;
     Name        = AtributeValue(ref shortcutNode, "Name");
     Arguments   = AtributeValue(ref shortcutNode, "Arguments");
     Description = AtributeValue(ref shortcutNode, "Description");
     TargetId    = AtributeValue(ref shortcutNode, "Target");
     FolderId    = AtributeValue(ref shortcutNode, "Folder");
     IconId      = AtributeValue(ref shortcutNode, "Icon");
     if (!String.IsNullOrEmpty(IconId))
     {
         IconIndex = VdProduct.AtrToInt(AtributeValue(ref shortcutNode, "IconIndex"));
     }
     WorkingFolderId = AtributeValue(ref shortcutNode, "WorkingFolder");
     IsFolder        = ((TargetId == FolderId) && (FolderId == WorkingFolderId));
 }
Example #3
0
        public VdFile(XmlNode fileNode)
        {
            Id         = fileNode.Name;
            SourceName = AtributeValue(ref fileNode, "SourcePath");
            DestName   = AtributeValue(ref fileNode, "TargetName");
            FolderId   = AtributeValue(ref fileNode, "Folder");
            Exclude    = VdProduct.AtrToBool(AtributeValue(ref fileNode, "Exclude"));
            if (Details == null)
            {
                Details = new FileDetails();
            }

            // Font
            if (SourceName.Contains(".ttf") || DestName.Contains(".ttf"))
            {
                Details.Type  = FileType.Font;
                Details.IsOTF = false;
            }
            if (SourceName.Contains(".otf") || DestName.Contains(".otf"))
            {
                Details.Type  = FileType.Font;
                Details.IsOTF = true;
            }

            if (Details.Type == FileType.Font)
            {
                // Should be registered?
                if (AtributeValue(ref fileNode, "Register") == "5") // vsdrfFont
                {
                    Details.Register = true;
                }
            }
            // Type library (.tlb).
            if (SourceName.Contains(".tlb") || DestName.Contains(".tlb"))
            {
                Details.Type = FileType.Library;
                int regFile = int.Parse(AtributeValue(ref fileNode, "Register"));
                if (regFile > 1 && regFile < 5)
                {
                    Details.Register = true;
                }
            }

            // Is assembly?
            if (AtributeValue(ref fileNode, "AssemblyRegister") != null)
            {
                Details.Type = FileType.Assembly;
                int regFile = int.Parse(AtributeValue(ref fileNode, "AssemblyRegister"));
                if (regFile > 1 && regFile < 5)
                {
                    Details.Register = true;
                }
                Details.IsInGAC = VdProduct.AtrToBool(AtributeValue(ref fileNode, "AssemblyIsInGAC"));
                Details.AsmName = AtributeValue(ref fileNode, "AssemblyAsmDisplayName");
            }

            // Register File?
            if (Details.Type == FileType.File)
            {
                int regFile = int.Parse(AtributeValue(ref fileNode, "Register"));
                if (regFile > 1 && regFile < 5)
                {
                    Details.Register = true;
                }
            }
        }
Example #4
0
        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)
            {
            }
        }