public bool Contains( Kit kit ) { return KitMap.ContainsValue( kit ); }
public void Add( Kit kit ) { KitMap.Add( kit.Name, kit ); Save(); }
public static List<Kit> LoadData(string KitsLocation) { KitList = new List<Kit>(); XmlDocument xmlReader = new XmlDocument(); xmlReader.Load(KitsLocation); foreach (XmlElement element in xmlReader.DocumentElement.ChildNodes) { Kit kit = new Kit() { ItemList = new Dictionary<Int32, Int32>() }; foreach (XmlNode nodeList in element.ChildNodes) { switch (nodeList.Name.Trim().ToLower()) { case "name": { kit.Name = nodeList.InnerText; break; } case "description": { kit.Description = nodeList.InnerText; break; } case "item": { try { int ID = Convert.ToInt32(nodeList.Attributes["id"].Value); int Stack = Convert.ToInt32(nodeList.Attributes["amount"].Value); kit.ItemList.Add(ID, Stack); } catch { } break; } } } if (kit.ItemList.Count > 0) //Kits need data { KitList.Add(kit); } } return KitList; }
public void Add( Kit kit ) { KitMap.Add( kit.Name.ToLowerInvariant(), kit ); Save(); }
public static void WriteKitElement(XmlWriter xmlWriter, Kit Kit) { xmlWriter.WriteStartElement("kit"); xmlWriter.WriteStartElement("name"); xmlWriter.WriteString(Kit.Name); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("description"); xmlWriter.WriteString(Kit.Description); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("item"); foreach (KeyValuePair<Int32, Int32> Item in Kit.ItemList) { xmlWriter.WriteAttributeString("id", Item.Key.ToString()); xmlWriter.WriteAttributeString("amount", Item.Value.ToString()); } xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); }