/// <summary> /// Asynchronously executes the specified request, with the specified authenticator, for the specified ViewModel type. /// </summary> public async Task ExecuteAsync <TViewModel, TToken, TSession>(ITwoStepAuthenticator <TToken, TSession> authenticator, Func <TSession, Task> attempt) where TViewModel : ViewModel <NoParameter> where TToken : IAuthenticationToken where TSession : class { var session = LoadSession <TSession>(typeof(TViewModel)); if (session == null) { var token = await authenticator.GetTokenAsync(); if (await _authenticator.AuthenticateAsync(_credentials.UserName, _credentials.Password, token.AuthenticationKey)) { session = await authenticator.GetSessionAsync(token); SaveSession(typeof(TViewModel), session); } else { _mainSettings.SessionStatus = SessionStatus.NotLoggedIn; return; } } await attempt(session); }
public Task ExecuteAsync <TViewModel, TToken, TSession>(ITwoStepAuthenticator <TToken, TSession> authenticator, Func <TSession, Task> attempt) where TViewModel : ViewModel <NoParameter> where TToken : IAuthenticationToken where TSession : class { return(attempt(null)); }