public static void OpenXml() { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Choose a Map XML File to read"; dlg.Filter = "XML File (*.xml)|*.xml"; dlg.CheckFileExists = true; dlg.CheckPathExists = true; DialogResult result = dlg.ShowDialog(); if (result == DialogResult.OK || result == DialogResult.Yes) { FileStream s = dlg.OpenFile() as FileStream; XMLIO.Read(s); s.Close(); } }
public static void SaveXml() { SaveFileDialog dlg = new SaveFileDialog(); dlg.Title = "Choose a path to output"; dlg.Filter = "XML File (*.xml)|*.xml"; dlg.AddExtension = true; dlg.CheckPathExists = true; dlg.OverwritePrompt = true; DialogResult result = dlg.ShowDialog(); if (result == DialogResult.OK || result == DialogResult.Yes) { Stream s = dlg.OpenFile(); XMLIO.Write(s); s.Close(); } }
public static void Parse(VEObject obj, XmlElement xml) { string typename = obj.GetType().FullName; if (!TypeDict.ContainsKey(typename)) { throw new Exception("Object [" + obj.ID + "] ToXML failed: Unknown Type"); } XMLMemberCollection mc = TypeDict[typename]; foreach (XMLMemberDesc mem in mc.Members) { object value = XMLIO.ReadValue(xml, mem.Attr, mem.Type, mem.Necessary, mem.DefaultValue); if (value != null) { mem.SetValue(obj, value); } } }
public static string ToXML(VEObject obj) { string typename = obj.GetType().FullName; if (!TypeDict.ContainsKey(typename)) { Debug.LogError("Object [" + obj.ID + "] ToXML failed: Unknown Type"); return(""); } XMLMemberCollection mc = TypeDict[typename]; string xml = "<" + mc.Name + " "; foreach (XMLMemberDesc mem in mc.Members) { xml += XMLIO.WriteValue(mem.Attr, mem.GetValue(obj), mem.Type, mem.Necessary, mem.DefaultValue); } xml += "/>\r\n"; return(xml); }