private static XmlNode GetXMLNodeForVSS(XmlDocument doc, VSS.VSS_Entry entry, VSS.VSS_Entry parent = null) { if (parent == null) { var node = doc.CreateElement(entry.Hotkey.ToString()); var desc = doc.CreateAttribute(varDescription); desc.InnerText = entry.Description; node.Attributes.Append(desc); foreach (var child in entry.Nodes) { if (child.GetType() == typeof(VSS.VSS_Entry_Group)) { node.AppendChild(GetXMLNodeForVSS(doc, (VSS.VSS_Entry_Group)child, entry)); } else { node.AppendChild(GetXMLNodeForVSS(doc, (VSS.VSS_Entry_Sound)child, entry)); } } doc.AppendChild(node); return(node); } else { if (entry.GetType() == typeof(VSS.VSS_Entry_Group)) { var node = doc.CreateElement(entry.Hotkey.ToString()); var desc = doc.CreateAttribute(varDescription); desc.InnerText = entry.Description; node.Attributes.Append(desc); var tmpCast = (VSS.VSS_Entry_Group)entry; foreach (var child in tmpCast.Nodes) { if (child.GetType() == typeof(VSS.VSS_Entry_Group)) { node.AppendChild(GetXMLNodeForVSS(doc, (VSS.VSS_Entry_Group)child, entry)); } else { node.AppendChild(GetXMLNodeForVSS(doc, (VSS.VSS_Entry_Sound)child, entry)); } } return(node); } else { var node = doc.CreateElement(entry.Hotkey.ToString()); var desc = doc.CreateAttribute(varDescription); desc.InnerText = entry.Description; var sound = doc.CreateAttribute(varSoundPath); sound.InnerText = ((VSS.VSS_Entry_Sound)entry).Filepath; node.Attributes.Append(desc); node.Attributes.Append(sound); return(node); } } }
public static void SaveVSSBase(string XmlPath, VSS.VSS_Entry rootVSSNode) { XmlDocument doc = new XmlDocument(); XmlNode ROOTNODE = GetXMLNodeForVSS(doc, rootVSSNode); var parentDir = Directory.GetParent(XmlPath); if (!parentDir.Exists) { parentDir.Create(); } doc.Save(XmlPath); }