Ejemplo n.º 1
0
        public static XMPPSettings ReadSettings()//(string filename)
        {
            if (File.Exists(filename))
            {
                XmlSerializer formatter = new XmlSerializer(typeof(XMPPSettings));

                using (StreamReader fs = new StreamReader(filename, Encoding.GetEncoding(1251), false))
                {
                    XMPPSettings settings = (XMPPSettings)formatter.Deserialize(fs);
                    fs.Close();
                    return(settings);
                }
            }
            else
            {
                XMPPSettings xMPPSettings = new XMPPSettings();
                xMPPSettings.Enable          = false;
                xMPPSettings.Server          = "127.0.0.1";
                xMPPSettings.Port            = 8080;
                xMPPSettings.Domain          = "domain.ru";
                xMPPSettings.AutoReconnect   = 100;
                xMPPSettings.User            = "******";
                xMPPSettings.Password        = "******";
                xMPPSettings.MessageTemplate = "У Вас новое уведомление!";

                XMPPConfig.SaveSettings(xMPPSettings);

                return(xMPPSettings);
            }
        }
Ejemplo n.º 2
0
        public static void SaveSettings(XMPPSettings settings)
        {
            XmlSerializer formatter = new XmlSerializer(typeof(XMPPSettings));
            TextWriter    writer    = new StreamWriter(filename, false, Encoding.GetEncoding(1251));

            formatter.Serialize(writer, settings);
            writer.Close();
        }