Esempio n. 1
0
        public void Save(PasswordDictionary passwords)
        {
            var serializer = new XmlSerializer(typeof(PasswordDictionary));

            using (var sw = new StreamWriter(_fileName))
                serializer.Serialize(sw, passwords);
        }
Esempio n. 2
0
        private PasswordDictionary LoadFromFile()
        {
            PasswordDictionary passwords;

            try
            {
                var serializer = new XmlSerializer(typeof(PasswordDictionary));
                using (var sr = new StreamReader(_fileName))
                    passwords = (PasswordDictionary)serializer.Deserialize(sr);
            }
            catch (InvalidOperationException ex) when(ex.InnerException is XmlException)
            {
                // Fail silently as the worst case is just some remembered passwords are lost
                // the xml file will be regenerated the next time a password is saved.
                passwords = new PasswordDictionary();
            }
            return(passwords);
        }
Esempio n. 3
0
 public PasswordManager(IPasswordStore passwordStore)
 {
     _passwordStore = passwordStore;
     _passwords     = _passwordStore.Load();
 }