예제 #1
0
        public bool Serialize(string fileName)
        {
            XmlSerializer s  = null;
            StreamWriter  sw = null;

            try
            {
                sw = new StreamWriter(fileName);
                s  = new XmlSerializer(typeof(MailConfig));

                RijndaelCrypto crypto = new RijndaelCrypto();
                string         pass   = _password;
                _password = crypto.Encrypt(_password);
                s.Serialize(sw, this);
                _password = pass;
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                    sw = null;
                }

                if (s != null)
                {
                    s = null;
                }
            }
        }
예제 #2
0
        public bool Deserialize(string fileName)
        {
            XmlSerializer s  = null;
            StreamReader  sr = null;

            try
            {
                s  = new XmlSerializer(typeof(MailConfig));
                sr = new StreamReader(fileName);
                MailConfig mailConfig = (MailConfig)s.Deserialize(sr);
                _senderMail    = mailConfig.SenderMail;
                _useSMTPServer = mailConfig.UseSMTPServer;
                _server        = mailConfig.Server;
                _port          = mailConfig.Port;
                _username      = mailConfig.Username;
                RijndaelCrypto crypto = new RijndaelCrypto();
                _password  = crypto.Decrypt(mailConfig.Password);
                _signature = mailConfig.Signature;

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                    sr = null;
                }

                if (s != null)
                {
                    s = null;
                }
            }
        }
예제 #3
0
        public bool Deserialize(string fileName)
        {
            XmlSerializer s  = null;
            StreamReader  sr = null;

            try
            {
                s  = new XmlSerializer(typeof(MySQLConnectionInfo));
                sr = new StreamReader(fileName);
                MySQLConnectionInfo connectionInfo = (MySQLConnectionInfo)s.Deserialize(sr);
                Server   = connectionInfo.Server;
                Database = connectionInfo.Database;
                User     = connectionInfo.User;
                Password = connectionInfo.Password;
                RijndaelCrypto crypto = new RijndaelCrypto();
                Password = crypto.Decrypt(connectionInfo.Password);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                    sr = null;
                }

                if (s != null)
                {
                    s = null;
                }
            }
        }