private async void InjectAccountPickerAsync() { IVsAccountManagementService vsAccountManagementService = ServiceProvider.GlobalProvider.GetService(typeof(SVsAccountManagementService)) as IVsAccountManagementService; if (vsAccountManagementService == null) { return; } AccountPickerOptions options = new AccountPickerOptions(Window.GetWindow(this), "VS Azure Tooling") { IsCompactHeight = false, UseWindowsPresentationFoundationStyle = false, IsAuthenticationStateUIEnabled = true }; EnsureRMAuthenticationManager(); _accountPicker = await vsAccountManagementService.CreateWpfAccountPickerAsync(options); AccountPickerHostControl.Content = _accountPicker.Control; _accountPicker.PropertyChanged += OnAccountPickerPropertyChanged; _accountPicker.SelectedAccount = await AzureAuthenticationManager.GetCurrentVSAccountAsync(); UpdateSettings(); }
private async Task <AzureAuthenticationManager> CreateAccountManager(AccountTokenWrapper currentAccount, IEnumerable <IAzureUserAccountSubscriptionContext> subscriptions, bool shouldFail = false) { AzureAuthenticationManager azureAuthenticationManager = new AzureAuthenticationManager(); azureAuthenticationManager.SetServiceProvider(serviceProvider); if (currentAccount != null) { await azureAuthenticationManager.SetCurrentAccountAsync(currentAccount); } if (!shouldFail) { resourceManagerMock.Setup(x => x.GetSubscriptionContextsAsync(It.IsAny <IAzureUserAccount>())).Returns(Task.FromResult(subscriptions)); } else { resourceManagerMock.Setup(x => x.GetSubscriptionContextsAsync(It.IsAny <IAzureUserAccount>())).Throws(new Exception()); } return(azureAuthenticationManager); }