blob: 41af6a55ac4661f4041c83523eb86254011142b7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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;
}
}
|