Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Commit 078a185

Browse files
Small code clean-up
1 parent f0109f0 commit 078a185

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ You can find example projects in the repository too.
223223
"Durable": true,
224224
"AutoDelete": false,
225225
"DeadLetterExchange": "default.dlx.exchange",
226-
"RequeueFailedMessages": true
226+
"RequeueFailedMessages": true,
227227
"Queues": [
228228
{
229229
"Name": "myqueue",

src/Examples.ConsumerHost/ConsumingService.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Examples.ConsumerHost
99
{
10-
public class ConsumingService : IHostedService, IDisposable
10+
public class ConsumingService : IHostedService
1111
{
1212
readonly IQueueService _queueService;
1313
readonly ILogger<ConsumingService> _logger;
@@ -32,7 +32,5 @@ public Task StopAsync(CancellationToken cancellationToken)
3232
_logger.LogInformation("Stopping consuming.");
3333
return Task.CompletedTask;
3434
}
35-
36-
public void Dispose() => _queueService?.Dispose();
3735
}
3836
}

src/RabbitMQ.Client.Core.DependencyInjection/RabbitMqClientDependencyInjectionExtensions.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ public static IServiceCollection AddExchange(this IServiceCollection services, s
4545

4646
var options = new RabbitMqExchangeOptions();
4747
configuration.Bind(options);
48-
var exchange = new RabbitMqExchange { Name = exchangeName, Options = options };
49-
var service = new ExchangeServiceDescriptor(typeof(RabbitMqExchange), exchange)
50-
{
51-
ExchangeName = exchangeName
52-
};
53-
services.Add(service);
54-
return services;
48+
return services.AddExchange(exchangeName, options);
5549
}
5650

5751
/// <summary>
@@ -61,7 +55,7 @@ public static IServiceCollection AddExchange(this IServiceCollection services, s
6155
/// <param name="exchangeName">Exchange name.</param>
6256
/// <param name="options">Exchange configuration <see cref="RabbitMqExchangeOptions"/>.</param>
6357
/// <returns>Service collection.</returns>
64-
public static IServiceCollection AddExchange(this IServiceCollection services, string exchangeName, RabbitMqExchangeOptions options = null)
58+
public static IServiceCollection AddExchange(this IServiceCollection services, string exchangeName, RabbitMqExchangeOptions options)
6559
{
6660
var exchangeExists = services.Any(x => x.ServiceType == typeof(RabbitMqExchange)
6761
&& x.Lifetime == ServiceLifetime.Singleton

0 commit comments

Comments
 (0)