diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2021-03-31 18:00:22 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2021-03-31 18:00:22 +0200 |
| commit | e6ca7a484d9cc213fb00c34ebf7cb55ace892c04 (patch) | |
| tree | e885d823c224d55503286b1dab207fcc7c5c68d1 /src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs | |
| download | dotnet-vipps-ecommerce-e6ca7a484d9cc213fb00c34ebf7cb55ace892c04.tar.xz dotnet-vipps-ecommerce-e6ca7a484d9cc213fb00c34ebf7cb55ace892c04.zip | |
Initial commit
Diffstat (limited to 'src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs')
| -rw-r--r-- | src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs b/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..d9c9769 --- /dev/null +++ b/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs @@ -0,0 +1,28 @@ +using System; +using IOL.VippsEcommerce.Models; +using Microsoft.Extensions.DependencyInjection; + +namespace IOL.VippsEcommerce +{ + public static class ServiceCollectionExtensions + { + /// <summary> + /// Configures and adds the VippsEcommerceService to your DI. + /// </summary> + /// <param name="services">Servicecollection to add VippsEcommerceService to.</param> + /// <param name="configuration"></param> + /// <returns></returns> + public static IServiceCollection AddVippsEcommerceService( + this IServiceCollection services, + Action<VippsConfiguration> configuration + ) { + if (services == null) throw new ArgumentNullException(nameof(services)); + if (configuration == null) throw new ArgumentNullException(nameof(configuration)); + + services.Configure(configuration); + services.AddHttpClient<IVippsEcommerceService, VippsEcommerceService>(); + services.AddScoped<IVippsEcommerceService, VippsEcommerceService>(); + return services; + } + } +}
\ No newline at end of file |
