public ExchangeProfileViewModel(ProfileRegister register, ExchangeProfileDataStore.Factory storeFactory, ExchangeAuthenticationService authenticationService, AutoMapper.IMapper mapper) : base(register) { _storeFactory = storeFactory; _client = new GraphServiceClient( "https://graph.microsoft.com/v1.0", new DelegateAuthenticationProvider(async(request) => { try { var result = await authenticationService.AcquireTokenSilentAsync(EmailAddress); var token = result.AccessToken; request.Headers.Authorization = new AuthenticationHeaderValue("bearer", token); } catch (Exception ex) { IsAuthenticated = false; this.Log().Error(ex, $"Failed to silently authenticate {EmailAddress}."); } })); _mailService = new ExchangeMailService(register, _storeFactory, _client, mapper); var queryFactory = new RelayProfileDataQueryFactory(register.DataFilePath, path => storeFactory.Invoke(path, false)); MailBox = new MailBoxViewModel(queryFactory, _mailService); }
public ExchangeProfileProvider(ExchangeAuthenticationService authenticationService, ExchangeProfileDataStore.Factory storeFactory, AutoMapper.IMapper mapper) { _authenticationService = authenticationService; _storeFactory = storeFactory; _mapper = mapper; }