public static string GetBoxAttribute(string file, long boxId, ShieldBoxItem attribute) { XElement root = XElement.Load(file); XElement elem = root .Elements(ShieldBoxItem.ShieldBox.ToString()) .Single(itemName => itemName.Attribute(ShieldBoxItem.BoxId.ToString()).Value == boxId.ToString()); return elem.Attribute(attribute.ToString()).Value; }
public static void SetBoxAttribute(string file, long boxId, ShieldBoxItem attribute, string newValue) { XElement root = XElement.Load(file); XElement elem = root .Elements(ShieldBoxItem.ShieldBox.ToString()) .Single(itemName => itemName.Attribute(ShieldBoxItem.BoxId.ToString()).Value == boxId.ToString()); elem.Attribute(attribute.ToString()).Value = newValue; root.Save(file); }