Skip to content

Commit 85dac6d

Browse files
Copilotkamilbaczek
andcommitted
Fix null reference warning in EventBusModule files
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
1 parent fb1b8fc commit 85dac6d

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

  • Chapter-4-applying-tactical-domain-driven-design

Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Infrastructure/EventBus/EventBusModule.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ internal static IServiceCollection AddEventBus(this IServiceCollection services,
1818
configurator.UsingRabbitMq((context, factoryConfigurator) =>
1919
{
2020
var options = context.GetRequiredService<IOptions<EventBusOptions>>();
21-
var externalEventBusConfigured = options.Value is not null;
21+
var eventBusOptions = options.Value;
22+
var externalEventBusConfigured = eventBusOptions is not null;
2223
if (!externalEventBusConfigured)
2324
{
2425
return;
2526
}
2627

27-
var uri = options.Value.Uri;
28-
var username = options.Value.Username;
29-
var password = options.Value.Password;
28+
var uri = eventBusOptions.Uri;
29+
var username = eventBusOptions.Username;
30+
var password = eventBusOptions.Password;
3031

3132
if (!string.IsNullOrEmpty(uri))
3233
{

Chapter-4-applying-tactical-domain-driven-design/Fitnet/Src/Passes/Fitnet.Passes.Api/Common/EventBus/EventBusModule.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ internal static IServiceCollection AddEventBus(this IServiceCollection services,
2121
configurator.UsingRabbitMq((context, factoryConfigurator) =>
2222
{
2323
var options = context.GetRequiredService<IOptions<EventBusOptions>>();
24-
var externalEventBusConfigured = options.Value is not null;
24+
var eventBusOptions = options.Value;
25+
var externalEventBusConfigured = eventBusOptions is not null;
2526
if (!externalEventBusConfigured)
2627
{
2728
return;
2829
}
2930

30-
var uri = options.Value.Uri;
31-
var username = options.Value.Username;
32-
var password = options.Value.Password;
31+
var uri = eventBusOptions.Uri;
32+
var username = eventBusOptions.Username;
33+
var password = eventBusOptions.Password;
3334

3435
if (!string.IsNullOrEmpty(uri))
3536
{

0 commit comments

Comments
 (0)