public XElement Serialize([NotNull] string elementName) { if (elementName == null) { throw new ArgumentNullException("elementName"); } XElement root = new XElement(elementName); root.Add(new XAttribute("name", Name)); if (AccessSecurity.HasRestrictions) { root.Add(AccessSecurity.Serialize(AccessSecurityXmlTagName)); } if (BuildSecurity.HasRestrictions) { root.Add(BuildSecurity.Serialize(BuildSecurityXmlTagName)); } if (BackupInterval != BackupIntervalDefault) { root.Add(new XAttribute("backup", BackupInterval.ToSecondsString())); } if (Preload) { root.Add(new XAttribute("noUnload", true)); } if (IsHidden) { root.Add(new XAttribute("hidden", true)); } root.Add(BlockDB.SaveSettings()); if (!String.IsNullOrEmpty(LoadedBy)) { root.Add(new XElement("LoadedBy", LoadedBy)); } if (LoadedOn != DateTime.MinValue) { root.Add(new XElement("LoadedOn", LoadedOn.ToUnixTime())); } if (!String.IsNullOrEmpty(MapChangedBy)) { root.Add(new XElement("MapChangedBy", MapChangedBy)); } if (MapChangedOn != DateTime.MinValue) { root.Add(new XElement("MapChangedOn", MapChangedOn.ToUnixTime())); } XElement elEnv = new XElement(EnvironmentXmlTagName); if (CloudColor > -1) { elEnv.Add(new XAttribute("cloud", CloudColor)); } if (FogColor > -1) { elEnv.Add(new XAttribute("fog", FogColor)); } if (SkyColor > -1) { elEnv.Add(new XAttribute("sky", SkyColor)); } if (EdgeLevel > -1) { elEnv.Add(new XAttribute("level", EdgeLevel)); } if (EdgeBlock != Block.Water) { elEnv.Add(new XAttribute("edge", EdgeBlock)); } if (elEnv.HasAttributes) { root.Add(elEnv); } return(root); }