@@ -81,11 +81,8 @@ static void CheckExchangeExists(IServiceCollection services, string exchangeName
81
81
/// <param name="services">Service collection.</param>
82
82
/// <param name="routingKey">Routing key.</param>
83
83
/// <returns>Service collection.</returns>
84
- public static IServiceCollection AddMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey )
85
- where T : class , IMessageHandler
86
- {
87
- return services . AddInstanceTransient < IMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
88
- }
84
+ public static IServiceCollection AddMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey ) where T : class , IMessageHandler =>
85
+ services . AddInstanceTransient < IMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
89
86
90
87
/// <summary>
91
88
/// Add transient message handler.
@@ -94,11 +91,8 @@ public static IServiceCollection AddMessageHandlerTransient<T>(this IServiceColl
94
91
/// <param name="services">Service collection.</param>
95
92
/// <param name="routingKeys">Routing keys.</param>
96
93
/// <returns>Service collection.</returns>
97
- public static IServiceCollection AddMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
98
- where T : class , IMessageHandler
99
- {
100
- return services . AddInstanceTransient < IMessageHandler , T > ( routingKeys . ToList ( ) ) ;
101
- }
94
+ public static IServiceCollection AddMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , IMessageHandler =>
95
+ services . AddInstanceTransient < IMessageHandler , T > ( routingKeys . ToList ( ) ) ;
102
96
103
97
/// <summary>
104
98
/// Add singleton message handler.
@@ -107,11 +101,8 @@ public static IServiceCollection AddMessageHandlerTransient<T>(this IServiceColl
107
101
/// <param name="services">Service collection.</param>
108
102
/// <param name="routingKey">Routing key.</param>
109
103
/// <returns>Service collection.</returns>
110
- public static IServiceCollection AddMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey )
111
- where T : class , IMessageHandler
112
- {
113
- return services . AddInstanceSingleton < IMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
114
- }
104
+ public static IServiceCollection AddMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey ) where T : class , IMessageHandler =>
105
+ services . AddInstanceSingleton < IMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
115
106
116
107
/// <summary>
117
108
/// Add singleton message handler.
@@ -120,24 +111,18 @@ public static IServiceCollection AddMessageHandlerSingleton<T>(this IServiceColl
120
111
/// <param name="services">Service collection.</param>
121
112
/// <param name="routingKeys">Routing keys.</param>
122
113
/// <returns>Service collection.</returns>
123
- public static IServiceCollection AddMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
124
- where T : class , IMessageHandler
125
- {
126
- return services . AddInstanceSingleton < IMessageHandler , T > ( routingKeys . ToList ( ) ) ;
127
- }
128
-
114
+ public static IServiceCollection AddMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , IMessageHandler =>
115
+ services . AddInstanceSingleton < IMessageHandler , T > ( routingKeys . ToList ( ) ) ;
116
+
129
117
/// <summary>
130
118
/// Add transient async message handler.
131
119
/// </summary>
132
120
/// <typeparam name="T">Message handler type.</typeparam>
133
121
/// <param name="services">Service collection.</param>
134
122
/// <param name="routingKey">Routing key.</param>
135
123
/// <returns>Service collection.</returns>
136
- public static IServiceCollection AddAsyncMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey )
137
- where T : class , IAsyncMessageHandler
138
- {
139
- return services . AddInstanceTransient < IAsyncMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
140
- }
124
+ public static IServiceCollection AddAsyncMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey ) where T : class , IAsyncMessageHandler =>
125
+ services . AddInstanceTransient < IAsyncMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
141
126
142
127
/// <summary>
143
128
/// Add transient async message handler.
@@ -146,11 +131,8 @@ public static IServiceCollection AddAsyncMessageHandlerTransient<T>(this IServic
146
131
/// <param name="services">Service collection.</param>
147
132
/// <param name="routingKeys">Routing keys.</param>
148
133
/// <returns>Service collection.</returns>
149
- public static IServiceCollection AddAsyncMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
150
- where T : class , IAsyncMessageHandler
151
- {
152
- return services . AddInstanceTransient < IAsyncMessageHandler , T > ( routingKeys . ToList ( ) ) ;
153
- }
134
+ public static IServiceCollection AddAsyncMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , IAsyncMessageHandler =>
135
+ services . AddInstanceTransient < IAsyncMessageHandler , T > ( routingKeys . ToList ( ) ) ;
154
136
155
137
/// <summary>
156
138
/// Add singleton async message handler.
@@ -159,11 +141,8 @@ public static IServiceCollection AddAsyncMessageHandlerTransient<T>(this IServic
159
141
/// <param name="services">Service collection.</param>
160
142
/// <param name="routingKey">Routing key.</param>
161
143
/// <returns>Service collection.</returns>
162
- public static IServiceCollection AddAsyncMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey )
163
- where T : class , IAsyncMessageHandler
164
- {
165
- return services . AddInstanceSingleton < IAsyncMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
166
- }
144
+ public static IServiceCollection AddAsyncMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey ) where T : class , IAsyncMessageHandler =>
145
+ services . AddInstanceSingleton < IAsyncMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
167
146
168
147
/// <summary>
169
148
/// Add singleton async message handler.
@@ -172,11 +151,8 @@ public static IServiceCollection AddAsyncMessageHandlerSingleton<T>(this IServic
172
151
/// <param name="services">Service collection.</param>
173
152
/// <param name="routingKeys">Routing keys.</param>
174
153
/// <returns>Service collection.</returns>
175
- public static IServiceCollection AddAsyncMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
176
- where T : class , IAsyncMessageHandler
177
- {
178
- return services . AddInstanceSingleton < IAsyncMessageHandler , T > ( routingKeys . ToList ( ) ) ;
179
- }
154
+ public static IServiceCollection AddAsyncMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , IAsyncMessageHandler =>
155
+ services . AddInstanceSingleton < IAsyncMessageHandler , T > ( routingKeys . ToList ( ) ) ;
180
156
181
157
/// <summary>
182
158
/// Add transient non-cyclic message handler.
@@ -185,11 +161,8 @@ public static IServiceCollection AddAsyncMessageHandlerSingleton<T>(this IServic
185
161
/// <param name="services">Service collection.</param>
186
162
/// <param name="routingKey">Routing key.</param>
187
163
/// <returns>Service collection.</returns>
188
- public static IServiceCollection AddNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey )
189
- where T : class , INonCyclicMessageHandler
190
- {
191
- return services . AddInstanceTransient < INonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
192
- }
164
+ public static IServiceCollection AddNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey ) where T : class , INonCyclicMessageHandler =>
165
+ services . AddInstanceTransient < INonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
193
166
194
167
/// <summary>
195
168
/// Add transient non-cyclic message handler.
@@ -198,11 +171,8 @@ public static IServiceCollection AddNonCyclicMessageHandlerTransient<T>(this ISe
198
171
/// <param name="services">Service collection.</param>
199
172
/// <param name="routingKeys">Routing keys.</param>
200
173
/// <returns>Service collection.</returns>
201
- public static IServiceCollection AddNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
202
- where T : class , INonCyclicMessageHandler
203
- {
204
- return services . AddInstanceTransient < INonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
205
- }
174
+ public static IServiceCollection AddNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , INonCyclicMessageHandler =>
175
+ services . AddInstanceTransient < INonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
206
176
207
177
/// <summary>
208
178
/// Add singleton non-cyclic message handler.
@@ -211,11 +181,8 @@ public static IServiceCollection AddNonCyclicMessageHandlerTransient<T>(this ISe
211
181
/// <param name="services">Service collection.</param>
212
182
/// <param name="routingKey">Routing key.</param>
213
183
/// <returns>Service collection.</returns>
214
- public static IServiceCollection AddNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey )
215
- where T : class , INonCyclicMessageHandler
216
- {
217
- return services . AddInstanceSingleton < INonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
218
- }
184
+ public static IServiceCollection AddNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey ) where T : class , INonCyclicMessageHandler =>
185
+ services . AddInstanceSingleton < INonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
219
186
220
187
/// <summary>
221
188
/// Add singleton non-cyclic message handler.
@@ -224,11 +191,8 @@ public static IServiceCollection AddNonCyclicMessageHandlerSingleton<T>(this ISe
224
191
/// <param name="services">Service collection.</param>
225
192
/// <param name="routingKeys">Routing keys.</param>
226
193
/// <returns>Service collection.</returns>
227
- public static IServiceCollection AddNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
228
- where T : class , INonCyclicMessageHandler
229
- {
230
- return services . AddInstanceSingleton < INonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
231
- }
194
+ public static IServiceCollection AddNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , INonCyclicMessageHandler =>
195
+ services . AddInstanceSingleton < INonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
232
196
233
197
/// <summary>
234
198
/// Add transient async non-cyclic message handler.
@@ -237,11 +201,8 @@ public static IServiceCollection AddNonCyclicMessageHandlerSingleton<T>(this ISe
237
201
/// <param name="services">Service collection.</param>
238
202
/// <param name="routingKey">Routing key.</param>
239
203
/// <returns>Service collection.</returns>
240
- public static IServiceCollection AddAsyncNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey )
241
- where T : class , IAsyncNonCyclicMessageHandler
242
- {
243
- return services . AddInstanceTransient < IAsyncNonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
244
- }
204
+ public static IServiceCollection AddAsyncNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , string routingKey ) where T : class , IAsyncNonCyclicMessageHandler =>
205
+ services . AddInstanceTransient < IAsyncNonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
245
206
246
207
/// <summary>
247
208
/// Add transient async non-cyclic message handler.
@@ -250,11 +211,8 @@ public static IServiceCollection AddAsyncNonCyclicMessageHandlerTransient<T>(thi
250
211
/// <param name="services">Service collection.</param>
251
212
/// <param name="routingKeys">Routing keys.</param>
252
213
/// <returns>Service collection.</returns>
253
- public static IServiceCollection AddAsyncNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
254
- where T : class , IAsyncNonCyclicMessageHandler
255
- {
256
- return services . AddInstanceTransient < IAsyncNonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
257
- }
214
+ public static IServiceCollection AddAsyncNonCyclicMessageHandlerTransient < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , IAsyncNonCyclicMessageHandler =>
215
+ services . AddInstanceTransient < IAsyncNonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
258
216
259
217
/// <summary>
260
218
/// Add singleton async non-cyclic message handler.
@@ -263,11 +221,8 @@ public static IServiceCollection AddAsyncNonCyclicMessageHandlerTransient<T>(thi
263
221
/// <param name="services">Service collection.</param>
264
222
/// <param name="routingKey">Routing key.</param>
265
223
/// <returns>Service collection.</returns>
266
- public static IServiceCollection AddAsyncNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey )
267
- where T : class , IAsyncNonCyclicMessageHandler
268
- {
269
- return services . AddInstanceSingleton < IAsyncNonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
270
- }
224
+ public static IServiceCollection AddAsyncNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , string routingKey ) where T : class , IAsyncNonCyclicMessageHandler =>
225
+ services . AddInstanceSingleton < IAsyncNonCyclicMessageHandler , T > ( new [ ] { routingKey } . ToList ( ) ) ;
271
226
272
227
/// <summary>
273
228
/// Add singleton async non-cyclic message handler.
@@ -276,11 +231,8 @@ public static IServiceCollection AddAsyncNonCyclicMessageHandlerSingleton<T>(thi
276
231
/// <param name="services">Service collection.</param>
277
232
/// <param name="routingKeys">Routing keys.</param>
278
233
/// <returns>Service collection.</returns>
279
- public static IServiceCollection AddAsyncNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
280
- where T : class , IAsyncNonCyclicMessageHandler
281
- {
282
- return services . AddInstanceSingleton < IAsyncNonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
283
- }
234
+ public static IServiceCollection AddAsyncNonCyclicMessageHandlerSingleton < T > ( this IServiceCollection services , IEnumerable < string > routingKeys ) where T : class , IAsyncNonCyclicMessageHandler =>
235
+ services . AddInstanceSingleton < IAsyncNonCyclicMessageHandler , T > ( routingKeys . ToList ( ) ) ;
284
236
285
237
static IServiceCollection AddInstanceTransient < U , T > ( this IServiceCollection services , IEnumerable < string > routingKeys )
286
238
where U : class
0 commit comments