Exemplo n.º 1
0
        public void SaveAccounts()
        {
            List <AccountInfo> infos = new List <AccountInfo>();

            foreach (Account account in m_Accounts)
            {
                infos.Add(account.Info);
            }

            AccountsConfig config = new AccountsConfig();

            config.Accounts = infos;

            XmlSerializer serializer = new XmlSerializer(typeof(AccountsConfig));

            using (StreamWriter writer = new StreamWriter(m_FileName)) {
                serializer.Serialize(writer, config);
            }
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            if (File.Exists(m_FileName))
            {
                AccountsConfig config = null;
                try {
                    XmlSerializer serializer = new XmlSerializer(typeof(AccountsConfig));
                    using (StreamReader reader = new StreamReader(m_FileName)) {
                        config = (AccountsConfig)serializer.Deserialize(reader);
                    }
                } catch (Exception e) {
                    Console.Error.WriteLine(e);
                    File.Delete(m_FileName);
                }

                if (config != null)
                {
                    foreach (AccountInfo info in config.Accounts)
                    {
                        try {
                            AddAccount(new Account(info), false);
                        } catch (Exception ex) {
                            // FIXME: Show this error somewhere, mark AccountInfo invalid!
                            // FIXME: Have PreferencesDialog list AccountInfos instead of Accounts
                            // so that invalid accounts can be fixed.
                            Console.Error.WriteLine("ERROR WITH ACCOUNT SETTINGS: " + ex);
                        }
                    }
                }
            }

            /*
             * if (ServiceManager.Contains<ScreensaverService>()) {
             *      ScreensaverService screensaver = ServiceManager.Get<ScreensaverService>();
             *      screensaver.ActiveChanged +=HandleActiveChanged;
             * }
             */
        }
Exemplo n.º 3
0
        public void SaveAccounts()
        {
            List<AccountInfo> infos = new List<AccountInfo>();
            foreach (Account account in m_Accounts) {
                infos.Add(account.Info);
            }

            AccountsConfig config = new AccountsConfig();
            config.Accounts = infos;

            XmlSerializer serializer = new XmlSerializer(typeof(AccountsConfig));
            using (StreamWriter writer = new StreamWriter(m_FileName)) {
                serializer.Serialize(writer, config);
            }
        }