Ejemplo n.º 1
0
        public bool Read()
        {
            log.InfoFormat("Read user={0}", user);

            MemoryStream m = new MemoryStream(Config <byte[]>()["script"]);

            Stream s = CryptUtil.DecrytStream(m, password);

            try
            {
                XmlSerializer ser  = new XmlSerializer(typeof(Settings));
                XmlTextReader xmlr = new XmlTextReader(new StreamReader(s));
                settings = (Settings)ser.Deserialize(xmlr);
                xmlr.Close();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                s.Close();
            }
        }
Ejemplo n.º 2
0
        public void Write()
        {
            log.InfoFormat("Write user={0}", user);
            MemoryStream  m    = new MemoryStream();
            Stream        s    = CryptUtil.EncryptStream(m, password);
            XmlSerializer ser  = new XmlSerializer(typeof(Settings));
            XmlTextWriter xmlw = new XmlTextWriter(new StreamWriter(s));

            ser.Serialize(xmlw, settings);
            xmlw.Close();
            s.Close();
            Config <byte[]>()["script"] = m.ToArray();
        }