From e6ca7a484d9cc213fb00c34ebf7cb55ace892c04 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 31 Mar 2021 18:00:22 +0200 Subject: Initial commit --- .../ServiceCollectionExtensions.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs (limited to 'src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs') 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 + { + /// + /// Configures and adds the VippsEcommerceService to your DI. + /// + /// Servicecollection to add VippsEcommerceService to. + /// + /// + public static IServiceCollection AddVippsEcommerceService( + this IServiceCollection services, + Action configuration + ) { + if (services == null) throw new ArgumentNullException(nameof(services)); + if (configuration == null) throw new ArgumentNullException(nameof(configuration)); + + services.Configure(configuration); + services.AddHttpClient(); + services.AddScoped(); + return services; + } + } +} \ No newline at end of file -- cgit v1.3