Beispiel #1
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;
                }
            }
        }
        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;
                }
            }
        }