|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +using System; |
| 5 | +using Azure.Core.Extensions; |
| 6 | +using Azure.Data.Tables; |
| 7 | + |
| 8 | +namespace Microsoft.Extensions.Azure |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Extension methods to add <see cref="TableClientOptions"/> client to clients builder. |
| 12 | + /// </summary> |
| 13 | + public static class TableClientBuilderExtensions |
| 14 | + { |
| 15 | + /// <summary> |
| 16 | + /// Registers a <see cref="TableServiceClient"/> instance with the provided <paramref name="connectionString"/> |
| 17 | + /// </summary> |
| 18 | + public static IAzureClientBuilder<TableServiceClient, TableClientOptions> AddTableServiceClient<TBuilder>(this TBuilder builder, string connectionString) |
| 19 | + where TBuilder : IAzureClientFactoryBuilder |
| 20 | + { |
| 21 | + return builder.RegisterClientFactory<TableServiceClient, TableClientOptions>(options => new TableServiceClient(connectionString, options)); |
| 22 | + } |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Registers a <see cref="TableServiceClient"/> instance with the provided <paramref name="serviceUri"/> and <paramref name="sharedKeyCredential"/> |
| 26 | + /// </summary> |
| 27 | + public static IAzureClientBuilder<TableServiceClient, TableClientOptions> AddTableServiceClient<TBuilder>(this TBuilder builder, Uri serviceUri, TableSharedKeyCredential sharedKeyCredential) |
| 28 | + where TBuilder : IAzureClientFactoryBuilder |
| 29 | + { |
| 30 | + return builder.RegisterClientFactory<TableServiceClient, TableClientOptions>(options => new TableServiceClient(serviceUri, sharedKeyCredential, options)); |
| 31 | + } |
| 32 | + |
| 33 | + /// <summary> |
| 34 | + /// Registers a <see cref="TableServiceClient"/> instance with connection options loaded from the provided <paramref name="configuration"/> instance. |
| 35 | + /// </summary> |
| 36 | + public static IAzureClientBuilder<TableServiceClient, TableClientOptions> AddTableServiceClient<TBuilder, TConfiguration>(this TBuilder builder, TConfiguration configuration) |
| 37 | + where TBuilder : IAzureClientFactoryBuilderWithConfiguration<TConfiguration> |
| 38 | + { |
| 39 | + return builder.RegisterClientFactory<TableServiceClient, TableClientOptions>(configuration); |
| 40 | + } |
| 41 | + } |
| 42 | +} |
0 commit comments