From 538cf5713d8c9d6b8a3e3c822f987ba1155ec726 Mon Sep 17 00:00:00 2001 From: Mariana Rios Flores Date: Wed, 1 Apr 2020 16:08:57 -0700 Subject: [PATCH 1/2] add client builder extensions --- .../TextAnalyticsClientBuilderExtensions.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClientBuilderExtensions.cs diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClientBuilderExtensions.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClientBuilderExtensions.cs new file mode 100644 index 000000000000..67a793f1444e --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClientBuilderExtensions.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure; +using Azure.AI.TextAnalytics; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// + /// Extension methods to add client to clients builder. + /// + public static class TextAnalyticsClientBuilderExtensions + { + /// + /// Registers a instance with the provided . + /// + public static IAzureClientBuilder AddTextAnalyticsClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, credential) => new TextAnalyticsClient(endpoint, credential, options)); + } + + /// + /// Registers a instance with the provided and . + /// + public static IAzureClientBuilder AddTextAnalyticsClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory(options => new TextAnalyticsClient(endpoint, credential, options)); + } + + /// + /// Registers a instance with connection options loaded from the provided instance. + /// + public static IAzureClientBuilder AddTextAnalyticsClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} From 577236df52d4d57a85097debe205a69a50a28337 Mon Sep 17 00:00:00 2001 From: Mariana Rios Flores Date: Wed, 1 Apr 2020 16:10:10 -0700 Subject: [PATCH 2/2] changelog --- sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md index b9fc13697b46..c402e16a9ddf 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md @@ -9,6 +9,7 @@ ### Added - Refactor common properties from `DetectLanguageInput` and `TextDocumentInput` into it's own type `TextAnalyticsInput`. - Mock support for the Text Analytics client with respective samples. +- Integration for ASP.NET Core. ## 1.0.0-preview.3 (2020-03-10) ### Breaking changes