Skip to content

Commit 3c4f021

Browse files
isdanielppittle
authored andcommitted
Update ServiceCollectionExtensions.cs
Support to use Func<IServiceProvider, AWSOptions> to create AWSOptions object.
1 parent 5ff5638 commit 3c4f021

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

extensions/src/AWSSDK.Extensions.NETCore.Setup/ServiceCollectionExtensions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ namespace Microsoft.Extensions.DependencyInjection
3131
/// </summary>
3232
public static class ServiceCollectionExtensions
3333
{
34+
35+
/// <summary>
36+
/// Adds the AWSOptions object to the dependency injection framework providing information
37+
/// that will be used to construct Amazon service clients.
38+
/// </summary>
39+
/// <param name="collection"></param>
40+
/// <param name="implementationFactory">The factory that creates the service AWSOptions</param>
41+
/// <param name="lifetime">The lifetime of the AWSOptions. The default is Singleton.</param>
42+
/// <returns>Returns back the IServiceCollection to continue the fluent system of IServiceCollection.</returns>
43+
public static IServiceCollection AddDefaultAWSOptions(this IServiceCollection collection, Func<IServiceProvider, AWSOptions> implementationFactory, ServiceLifetime lifetime = ServiceLifetime.Singleton)
44+
{
45+
collection.Add(new ServiceDescriptor(typeof(AWSOptions), implementationFactory, lifetime));
46+
return collection;
47+
}
48+
3449
/// <summary>
3550
/// Adds the AWSOptions object to the dependency injection framework providing information
3651
/// that will be used to construct Amazon service clients.

0 commit comments

Comments
 (0)