-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWebApplicationBuilderExtensions.cs
More file actions
178 lines (168 loc) · 7.21 KB
/
Copy pathWebApplicationBuilderExtensions.cs
File metadata and controls
178 lines (168 loc) · 7.21 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// 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 class WebApplicationBuilderExtensions
{
/// <summary>
/// Add Rabbit Mq Stream System As Default.
/// </summary>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="configureOptions">The configure options.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqStreamSystemAsDefault(
this WebApplicationBuilder webApplicationBuilder,
Action<ConnectionOptions> configureOptions)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(ConnectionOptions.DefaultKey);
ArgumentNullException.ThrowIfNull(configureOptions);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystemAsDefault(configureOptions);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Stream System As Default.
/// </summary>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="configureOptions">The configure options.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqStreamSystemAsDefault(
this WebApplicationBuilder webApplicationBuilder,
Action<OptionsBuilder<ConnectionOptions>> configureOptions)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(ConnectionOptions.DefaultKey);
ArgumentNullException.ThrowIfNull(configureOptions);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystemAsDefault(configureOptions);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Stream System As Default.
/// </summary>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="configSectionPath">The config section path.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqStreamSystemAsDefault(
this WebApplicationBuilder webApplicationBuilder,
string configSectionPath)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(configSectionPath);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystemAsDefault(configSectionPath);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Stream System From Options As Default.
/// </summary>
/// <remarks>
/// It needs provided connection options.
/// </remarks>
/// <param name="webApplicationBuilder">The initial web application builder.</param>
/// <param name="optionName">The named option.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqStreamSystemFromOptionAsDefault(
this WebApplicationBuilder webApplicationBuilder,
string optionName)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(optionName);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystemFromOptionsAsDefault(optionName);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Stream System.
/// </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 AddRabbitMqStreamSystem(
this WebApplicationBuilder webApplicationBuilder,
string name,
Action<ConnectionOptions> configureOptions)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(configureOptions);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystem(name, configureOptions);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Stream System.
/// </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 AddRabbitMqStreamSystem(
this WebApplicationBuilder webApplicationBuilder,
string name,
Action<OptionsBuilder<ConnectionOptions>> configureOptions)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(configureOptions);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystem(name, configureOptions);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Stream System.
/// </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 AddRabbitMqStreamSystem(
this WebApplicationBuilder webApplicationBuilder,
string name,
string configSectionPath)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(configSectionPath);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystem(name, configSectionPath);
return webApplicationBuilder;
}
/// <summary>
/// Add Rabbit Mq Stream System From Option.
/// </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="optionName">The named option.</param>
/// <returns>The updated web application builder.</returns>
public static WebApplicationBuilder AddRabbitMqStreamSystemFromOption(
this WebApplicationBuilder webApplicationBuilder,
string name,
string optionName)
{
ArgumentNullException.ThrowIfNull(webApplicationBuilder);
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(optionName);
webApplicationBuilder
.Host
.AddRabbitMqStreamSystemFromOptions(name, optionName);
return webApplicationBuilder;
}
}