-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWebApplicationBuilderExtensions.Connection.cs
More file actions
101 lines (95 loc) · 3.91 KB
/
Copy pathWebApplicationBuilderExtensions.Connection.cs
File metadata and controls
101 lines (95 loc) · 3.91 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright (c) Escendit Ltd. All Rights Reserved.
// Licensed under the MIT. See LICENSE.txt file in the solution root for full license information.
namespace Microsoft.AspNetCore.Builder;
using Escendit.Extensions.DependencyInjection.RabbitMQ.Abstractions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
/// <summary>
/// Web Application Builder Extensions.
/// </summary>
public static partial class WebApplicationBuilderExtensions
{
/// <summary>
/// Add Rabbit Mq Connection.
/// </summary>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="name">The name.</param>
/// <param name="configureOptions">The configure options.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqConnection(
this WebApplicationBuilder webApplicationBuilder,
string name,
Action<ConnectionOptions> configureOptions)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(configureOptions);
webApplicationBuilder
.Host
.AddRabbitMqConnection(name, configureOptions);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Connection.
/// </summary>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="name">The name.</param>
/// <param name="configureOptions">The configure options.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqConnection(
this WebApplicationBuilder webApplicationBuilder,
string name,
Action<OptionsBuilder<ConnectionOptions>> configureOptions)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(configureOptions);
webApplicationBuilder
.Host
.AddRabbitMqConnection(name, configureOptions);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Connection.
/// </summary>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="name">The name.</param>
/// <param name="configSectionPath">The config section path.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqConnection(
this WebApplicationBuilder webApplicationBuilder,
string name,
string configSectionPath)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(configSectionPath);
webApplicationBuilder
.Host
.AddRabbitMqConnection(name, configSectionPath);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Connection From Factory.
/// </summary>
/// <remarks>
/// It needs provided connection options.
/// </remarks>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="name">The name.</param>
/// <param name="factoryName">The factory name.</param>
/// <returns>The updated host builder.</returns>
public static WebApplicationBuilder AddRabbitMqConnectionFromFactory(
this WebApplicationBuilder webApplicationBuilder,
string name,
string factoryName)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(factoryName);
webApplicationBuilder
.Host
.AddRabbitMqConnectionFromFactory(name, factoryName);
return webApplicationBuilder;
}
}