fCraft.BlockDB.SaveSettings C# (CSharp) Method

SaveSettings() public method

public SaveSettings ( ) : System.Xml.Linq.XElement
return System.Xml.Linq.XElement
        public XElement SaveSettings()
        {
            return SaveSettings( XmlRootName );
        }

Same methods

BlockDB::SaveSettings ( string rootName ) : System.Xml.Linq.XElement

Usage Example

Example #1
0
        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);
        }