private string StringSerialize(ServerIcons serverIcons)
        {
            try
            {
                var textWriter = WriterSerialize(serverIcons);
                var xml = textWriter.ToString();
                textWriter.Close();
                return xml;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in StringSerialize()");
            }

            return string.Empty;
        }
        private string StringSerialize(ServerIcons serverIcons)
        {
            try
            {
                var textWriter = WriterSerialize(serverIcons);
                var xml        = textWriter.ToString();
                textWriter.Close();
                return(xml);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in StringSerialize()");
            }

            return(string.Empty);
        }
        private TextWriter WriterSerialize(ServerIcons serverIcons)
        {
            try
            {
                TextWriter stringWriter = new StringWriter();
                serializer = new XmlSerializer(type);
                serializer.Serialize(stringWriter, serverIcons);
                stringWriter.Flush();
                return(stringWriter);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in WriterSerialize()");
            }

            return(null);
        }
        private TextWriter WriterSerialize(ServerIcons serverIcons)
        {
            try
            {
                TextWriter stringWriter = new StringWriter();
                serializer = new XmlSerializer(type);
                serializer.Serialize(stringWriter, serverIcons);
                stringWriter.Flush();
                return stringWriter;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in WriterSerialize()");
            }

            return null;
        }
        public XmlDocument Serialize(ServerIcons serverIcons)
        {
            try
            {
                var xml = StringSerialize(serverIcons);
                var doc = new XmlDocument { PreserveWhitespace = true };
                doc.LoadXml(xml);
                doc = Clean(doc);
                return doc;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in Serialize()");
            }

            return null;
        }
        public XmlDocument Serialize(ServerIcons serverIcons)
        {
            try
            {
                var xml = StringSerialize(serverIcons);
                var doc = new XmlDocument {
                    PreserveWhitespace = true
                };
                doc.LoadXml(xml);
                doc = Clean(doc);
                return(doc);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in Serialize()");
            }

            return(null);
        }
        public static bool WriteFile(string file, ServerIcons config)
        {
            var serializer = new ServerIconsSerializer();

            try
            {
                var xml = serializer.Serialize(config).OuterXml;
                using (var writer = new StreamWriter(file, false))
                {
                    writer.Write(xml);
                    writer.Flush();
                    writer.Close();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in WriteFile()");
            }

            return(false);
        }
        public static bool WriteFile(string file, ServerIcons config)
        {
            var serializer = new ServerIconsSerializer();

            try
            {
                var xml = serializer.Serialize(config).OuterXml;
                using (var writer = new StreamWriter(file, false))
                {
                    writer.Write(xml);
                    writer.Flush();
                    writer.Close();
                }

                return true;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex, "Exception in WriteFile()");
            }

            return false;
        }