public static void XMLWriter(ref AUTH Data, string file) { KKtXml Xml = new KKtXml(); if (File.Exists(file + ".xml")) { File.Delete(file + ".xml"); } XElement AuthDB = new XElement("AuthDB"); Xml.Compact = true; Xml.Writer(AuthDB, KKtText.ToASCII(BitConverter.GetBytes(Data.Signature)), "Signature"); if (Data.Category != null) { XElement Categories = new XElement("Categories"); Xml.Writer(Categories, Data.Category.Length.ToString(), "Length"); foreach (string category in Data.Category) { XElement Category = new XElement("Category"); Xml.Writer(Category, category, "Value"); Categories.Add(Category); } AuthDB.Add(Categories); } if (Data.UID != null) { XElement UIDs = new XElement("UIDs"); Xml.Writer(UIDs, Data.UID.Length.ToString(), "Length"); foreach (UID uid in Data.UID) { XElement UID = new XElement("UID"); if (uid.Category != "") { Xml.Writer(UID, uid.Category, "Category"); } if (uid.Size != -1) { Xml.Writer(UID, uid.Size.ToString(), "Size"); } if (uid.Value != "") { Xml.Writer(UID, uid.Value, "Value"); } UIDs.Add(UID); } AuthDB.Add(UIDs); } Xml.doc.Add(AuthDB); Xml.SaveXml(file + ".xml"); }
public static void XMLReader(ref AUTH Data, string file) { KKtXml Xml = new KKtXml(); Xml.OpenXml(file + ".xml", true); foreach (XElement AuthDB in Xml.doc.Elements("AuthDB")) { foreach (XAttribute Entry in AuthDB.Attributes()) { if (Entry.Name == "Signature") { Data.Signature = BitConverter.ToInt32(KKtText.ToASCII(Entry.Value), 0); } } foreach (XElement Child0 in AuthDB.Elements()) { if (Child0.Name == "Categories") { foreach (XAttribute Entry in Child0.Attributes()) { if (Entry.Name == "Length") { Data.Category = new string[int.Parse(Entry.Value)]; } } int i = 0; foreach (XElement Category in Child0.Elements()) { Data.Category[i] = ""; foreach (XAttribute Entry in Category.Attributes()) { if (Entry.Name == "Value") { Data.Category[i] = Entry.Value; } } i++; } } if (Child0.Name == "UIDs") { foreach (XAttribute Entry in Child0.Attributes()) { if (Entry.Name == "Length") { Data.UID = new UID[int.Parse(Entry.Value)]; } } int i = 0; foreach (XElement UID in Child0.Elements()) { Data.UID[i].Category = ""; Data.UID[i].Size = -1; Data.UID[i].Value = ""; foreach (XAttribute Entry in UID.Attributes()) { if (Entry.Name == "Category") { Data.UID[i].Category = Entry.Value; } if (Entry.Name == "Size") { Data.UID[i].Size = int.Parse(Entry.Value); } if (Entry.Name == "Value") { Data.UID[i].Value = Entry.Value; } } i++; } } } } }