Revision 437abfca trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
b/trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs | ||
---|---|---|
228 | 228 |
NotifyOfPropertyChange(()=>Settings); |
229 | 229 |
} |
230 | 230 |
|
231 |
public void AddPithosAccount() |
|
231 |
public async void AddPithosAccount()
|
|
232 | 232 |
{ |
233 |
var task=PithosAccount.RetrieveCredentialsAsync(Settings.PithosSite) |
|
234 |
.ContinueWith(t=> |
|
235 |
{ |
|
236 |
var credentials=t.Result; |
|
237 |
var account = Settings.Accounts.FirstOrDefault(act => act.AccountName == credentials.UserName); |
|
238 |
if (account == null) |
|
239 |
{ |
|
240 |
account=new AccountSettings{ |
|
241 |
AccountName=credentials.UserName, |
|
242 |
ApiKey=credentials.Password, |
|
243 |
UsePithos=true |
|
244 |
}; |
|
245 |
Settings.Accounts.Add(account); |
|
246 |
(Accounts as IProducerConsumerCollection<AccountSettings>).TryAdd(account); |
|
247 |
} |
|
248 |
else |
|
249 |
{ |
|
250 |
account.ApiKey=credentials.Password; |
|
251 |
} |
|
252 |
//SelectedAccountIndex= Settings.Accounts.IndexOf(account); |
|
253 |
CurrentAccount = account; |
|
254 |
NotifyOfPropertyChange(() => Accounts); |
|
255 |
NotifyOfPropertyChange(()=>Settings); |
|
256 |
}); |
|
257 |
((Task)task).WaitWithPumping(); |
|
233 |
var credentials=await PithosAccount.RetrieveCredentialsAsync(Settings.PithosSite); |
|
234 |
var account = Settings.Accounts.FirstOrDefault(act => act.AccountName == credentials.UserName); |
|
235 |
if (account == null) |
|
236 |
{ |
|
237 |
account=new AccountSettings{ |
|
238 |
AccountName=credentials.UserName, |
|
239 |
ApiKey=credentials.Password, |
|
240 |
UsePithos=true |
|
241 |
}; |
|
242 |
Settings.Accounts.Add(account); |
|
243 |
(Accounts as IProducerConsumerCollection<AccountSettings>).TryAdd(account); |
|
244 |
} |
|
245 |
else |
|
246 |
{ |
|
247 |
account.ApiKey=credentials.Password; |
|
248 |
} |
|
249 |
//SelectedAccountIndex= Settings.Accounts.IndexOf(account); |
|
250 |
CurrentAccount = account; |
|
251 |
NotifyOfPropertyChange(() => Accounts); |
|
252 |
NotifyOfPropertyChange(()=>Settings); |
|
258 | 253 |
} |
259 | 254 |
|
260 | 255 |
public void RemoveAccount() |
Also available in: Unified diff