public override XElement ToXml(string elementName = null) { if (string.IsNullOrEmpty(elementName)) { elementName = "SwimBreath"; } var root = new XElement(elementName); var airSourcesRoot = new XElement("AirSources"); foreach (var airSource in AirSources.OrderBy(a => a.Name)) { airSourcesRoot.Add(airSource.ToXml()); } root.Add(airSourcesRoot); var consumablesRoot = new XElement("Consumables"); foreach (var consumable in Consumables.OrderBy(c => c.Name)) { consumablesRoot.Add(consumable.ToXml()); } root.Add(consumablesRoot); var equipmentsRoot = new XElement("Equipments"); foreach (var equipment in Equipments) { equipmentsRoot.Add(equipment.ToXml()); } root.Add(equipmentsRoot); return(root); }