-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathIServiceCollectionExtensions.cs
More file actions
46 lines (44 loc) · 1.87 KB
/
IServiceCollectionExtensions.cs
File metadata and controls
46 lines (44 loc) · 1.87 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Contentstack.Core;
using Contentstack.Core.Configuration;
using Microsoft.Extensions.Configuration;
using System.Net.Http;
namespace Contentstack.AspNetCore
{
/// <summary>
/// Extension methods for IServiceCollection.
/// </summary>
public static class IServiceCollectionExtensions
{
/// <summary>
/// Adds Contentstack services to the IServiceCollection.
/// </summary>
/// <param name="services">The IServiceCollection.</param>
/// <param name="configuration">The IConfigurationRoot used to retrieve configuration from.</param>
/// <returns>The IServiceCollection.</returns>
public static IServiceCollection AddContentstack(this IServiceCollection services, IConfigurationRoot configuration)
{
services.AddOptions();
services.Configure<ContentstackOptions>(configuration.GetSection("ContentstackOptions"));
services.TryAddTransient<ContentstackClient>();
return services;
}
/// <summary>
/// Adds Contentstack services to the IServiceCollection.
/// </summary>
/// <param name="services">The IServiceCollection.</param>
/// <param name="configuration">The IConfiguration used to retrieve configuration from.</param>
/// <returns>The IServiceCollection.</returns>
public static IServiceCollection AddContentstack(this IServiceCollection services, IConfiguration configuration)
{
services.AddOptions();
services.Configure<ContentstackOptions>(configuration.GetSection("ContentstackOptions"));
services.TryAddTransient<ContentstackClient>();
return services;
}
}
}