private async void btnSave_Click(object sender, RoutedEventArgs e) { Account item = new Account(); item.Name = this.txtName.Text; item.SecretKey = this.txtSecretKey.Text; if (item.Name.Length == 0) { MessageDialog dialog = new MessageDialog("You need to provide a name for this account. Please try again.", "Validation Error"); await dialog.ShowAsync(); return; } item.RefreshCode(); if (item.SecretKey.Length == 0 || item.Code == null || item.Code.Length != 6) { MessageDialog dialog = new MessageDialog("The secret key you provided could not be validated. Please try again.", "Validation Error"); await dialog.ShowAsync(); return; } App.Accounts.Add(item); if (Frame.CanGoBack) Frame.GoBack(); }
public static void DeserializeRoamedAccounts() { PasswordVault vault = new PasswordVault(); App.Accounts.Clear(); foreach (var credential in vault.RetrieveAll()) { credential.RetrievePassword(); Account a = new Account(); a.Name = credential.UserName; a.SecretKey = credential.Password; App.Accounts.Add(a); } }
public static void DeserializeAccounts() { if (App.RoamAccountSecrets) { DeserializeRoamedAccounts(); } else { App.Accounts.Clear(); foreach (var value in ApplicationData.Current.LocalSettings.Values) { Account a = new Account(); a.Name = value.Key; a.SecretKey = value.Value as string; App.Accounts.Add(a); } } }