コード例 #1
0
 private static void SaveData(string filePath, AccountCollection sourceObj)
 {
     if (!string.IsNullOrEmpty(filePath) && sourceObj != null)
     {
         var json = NimUtility.Json.JsonParser.SerializeWithIndented(sourceObj);
         File.WriteAllText(filePath, json);
     }
 }
コード例 #2
0
        public static void SaveLoginAccounts(AccountCollection collection)
        {
            var path = System.IO.Path.Combine(System.Environment.CurrentDirectory, SettingFilePath);

            foreach (var item in collection.List)
            {
                item.Password = DESEncrypt(item.Password, DESKey, DESIV);
            }
            SaveData(path, collection);
        }
コード例 #3
0
        private static AccountCollection LoadData(string filePath)
        {
            AccountCollection result = null;

            if (File.Exists(filePath))
            {
                var content = File.ReadAllText(filePath);
                result = NimUtility.Json.JsonParser.Deserialize <AccountCollection>(content);
            }

            return(result);
        }
コード例 #4
0
 private void InitLoginAccount()
 {
     _accounts = AccountManager.GetAccountList();
     if (_accounts != null)
     {
         foreach (var item in _accounts.List)
         {
             if (!UserNameComboBox.Items.Contains(item.Name))
             {
                 UserNameComboBox.Items.Add(item.Name);
             }
         }
         UserNameComboBox.Text = _accounts.List[_accounts.LastIndex].Name;
         textBox2.Text         = _accounts.List[_accounts.LastIndex].Password;
     }
 }
コード例 #5
0
        private void SaveLoginAccount()
        {
            if (_accounts == null)
            {
                _accounts = new AccountCollection();
            }
            var index = _accounts.IndexOf(_userName);

            if (index != -1)
            {
                _accounts.List[index].Password = _password;
                _accounts.LastIndex            = index;
            }
            else
            {
                Account account = new Account();
                account.Name     = _userName;
                account.Password = _password;
                _accounts.List.Insert(0, account);
                _accounts.LastIndex = 0;
            }
            AccountManager.SaveLoginAccounts(_accounts);
        }