Skip to content

Commit 45b2c56

Browse files
committed
Add TryAddCredentialsFactory overload
1 parent f7e2580 commit 45b2c56

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,22 @@ public static IServiceCollection TryAddCredentialsFactory(this IServiceCollectio
8888
public static IServiceCollection AddCredentialsFactory(
8989
this IServiceCollection collection,
9090
Func<IServiceProvider, IAWSCredentialsFactory> awsCredentialsFactoryFunc,
91-
ServiceLifetime lifetime = ServiceLifetime.Singleton,
92-
bool tryAdd = false)
91+
ServiceLifetime lifetime = ServiceLifetime.Singleton)
92+
{
93+
return collection.AddCredentialsFactoryInternal(awsCredentialsFactoryFunc, lifetime, tryAdd: false);
94+
}
95+
96+
/// <summary>
97+
/// Adds a IAWSCredentialsFactory object obtained via th provided awsCredentialsFactoryFunc to the dependency
98+
/// injection framework if no IAWSCredentialsFactory is already registered.
99+
/// This factory will be used to create the credentials for the Amazon service clients.
100+
/// </summary>
101+
public static IServiceCollection TryAddCredentialsFactory(
102+
this IServiceCollection collection,
103+
Func<IServiceProvider, IAWSCredentialsFactory> awsCredentialsFactoryFunc,
104+
ServiceLifetime lifetime = ServiceLifetime.Singleton)
93105
{
94-
return collection.AddCredentialsFactoryInternal(awsCredentialsFactoryFunc, lifetime, tryAdd);
106+
return collection.AddCredentialsFactoryInternal(awsCredentialsFactoryFunc, lifetime, tryAdd: true);
95107
}
96108

97109
/// <summary>

0 commit comments

Comments
 (0)