private static async void TestApiKeysAsync() { List <Task> testTasks = new List <Task> { !string.IsNullOrEmpty(SettingsHelper.Instance.FaceApiKey) ? CognitiveServiceApiKeyTester.TestFaceApiKeyAsync(SettingsHelper.Instance.FaceApiKey, SettingsHelper.Instance.FaceApiKeyEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.VisionApiKey) ? CognitiveServiceApiKeyTester.TestComputerVisionApiKeyAsync(SettingsHelper.Instance.VisionApiKey, SettingsHelper.Instance.VisionApiKeyEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.BingSearchApiKey) ? CognitiveServiceApiKeyTester.TestBingSearchApiKeyAsync(SettingsHelper.Instance.BingSearchApiKey) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.BingAutoSuggestionApiKey) ? CognitiveServiceApiKeyTester.TestBingAutosuggestApiKeyAsync(SettingsHelper.Instance.BingAutoSuggestionApiKey) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.TextAnalyticsKey) ? CognitiveServiceApiKeyTester.TestTextAnalyticsApiKeyAsync(SettingsHelper.Instance.TextAnalyticsKey, SettingsHelper.Instance.TextAnalyticsApiKeyEndpoint) : Task.CompletedTask }; try { await Task.WhenAll(testTasks); } catch (Exception) { ShowToastNotification("Failure validating your API Keys. Please run the Key Validation Test in the Settings Page for more details."); } }
private static async void TestApiKeysAsync() { List <Task> testTasks = new List <Task> { !string.IsNullOrEmpty(SettingsHelper.Instance.FaceApiKey) ? CognitiveServiceApiKeyTester.TestFaceApiKeyAsync(SettingsHelper.Instance.FaceApiKey, SettingsHelper.Instance.FaceApiKeyEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.VisionApiKey) ? CognitiveServiceApiKeyTester.TestComputerVisionApiKeyAsync(SettingsHelper.Instance.VisionApiKey, SettingsHelper.Instance.VisionApiKeyEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.CustomVisionTrainingApiKey) ? CognitiveServiceApiKeyTester.TestCustomVisionTrainingApiKeyAsync(SettingsHelper.Instance.CustomVisionTrainingApiKey, SettingsHelper.Instance.CustomVisionTrainingApiKeyEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.BingSearchApiKey) ? CognitiveServiceApiKeyTester.TestBingSearchApiKeyAsync(SettingsHelper.Instance.BingSearchApiKey) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.TextAnalyticsKey) ? CognitiveServiceApiKeyTester.TestTextAnalyticsApiKeyAsync(SettingsHelper.Instance.TextAnalyticsKey, SettingsHelper.Instance.TextAnalyticsApiKeyEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.TranslatorTextApiKey) ? CognitiveServiceApiKeyTester.TestTranslatorTextApiKeyAsync(SettingsHelper.Instance.TranslatorTextApiKey, SettingsHelper.Instance.TranslatorTextApiRegion) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.AnomalyDetectorApiKey) ? CognitiveServiceApiKeyTester.TestAnomalyDetectorApiKeyAsync(SettingsHelper.Instance.AnomalyDetectorApiKey, SettingsHelper.Instance.AnomalyDetectorKeyEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.SpeechApiKey) ? CognitiveServiceApiKeyTester.TestSpeechApiKeyAsync(SettingsHelper.Instance.SpeechApiKey, SettingsHelper.Instance.SpeechApiEndpoint) : Task.CompletedTask, !string.IsNullOrEmpty(SettingsHelper.Instance.FormRecognizerApiKey) ? CognitiveServiceApiKeyTester.TestFormRecognizerApiKeyAsync(SettingsHelper.Instance.FormRecognizerApiKey, SettingsHelper.Instance.FormRecognizerApiKeyEndpoint) : Task.CompletedTask, }; try { await Task.WhenAll(testTasks); } catch (Exception) { ShowToastNotification("Failure validating your API Keys. Please run the Key Validation Test in the Settings Page for more details."); } }