-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathServiceCollectionExtension.cs
More file actions
32 lines (30 loc) · 1.46 KB
/
Copy pathServiceCollectionExtension.cs
File metadata and controls
32 lines (30 loc) · 1.46 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
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace SimpleRabbit.NetCore
{
public static class ServiceCollectionExtension
{
/// <summary>
/// configure the default <see cref="RabbitConfiguration"/> to <see cref="IServiceCollection"/>
/// </summary>
/// <param name="services"> the collection to add this to</param>
/// <param name="config">the section of the configuration to use</param>
/// <returns>the <see cref="IServiceCollection"/></returns>
public static IServiceCollection AddRabbitConfiguration(this IServiceCollection services, IConfigurationSection config)
{
return services.Configure<RabbitConfiguration>(config);
}
/// <summary>
/// Add a named <see cref="RabbitConfiguration"/> to <see cref="IServiceCollection"/>
/// </summary>
/// <param name="services">the collection to add this to</param>
/// <param name="name">the name or key this is accessible by</param>
/// <param name="config">the section of the configuration to use</param>
/// <returns>the <see cref="IServiceCollection"/></returns>
public static IServiceCollection AddRabbitConfiguration(this IServiceCollection services, string name, IConfigurationSection config)
{
return services.Configure<RabbitConfiguration>(name, config);
}
}
}