diff --git a/src/Fluxera.Entity/DomainEvents/DomainEventDispatcher.cs b/src/Fluxera.Entity/DomainEvents/DomainEventDispatcher.cs
index c2c25af..ab785af 100644
--- a/src/Fluxera.Entity/DomainEvents/DomainEventDispatcher.cs
+++ b/src/Fluxera.Entity/DomainEvents/DomainEventDispatcher.cs
@@ -29,7 +29,7 @@ public DomainEventDispatcher(IServiceProvider serviceProvider)
}
///
- public async Task DispatchAsync(IDomainEvent domainEvent)
+ public virtual async Task DispatchAsync(IDomainEvent domainEvent)
{
Type eventType = domainEvent.GetType();
Type eventHandlerType = typeof(IDomainEventHandler<>).MakeGenericType(eventType);
diff --git a/src/Fluxera.Entity/DomainEvents/DomainEventHandlerBuilder.cs b/src/Fluxera.Entity/DomainEvents/DomainEventHandlerBuilder.cs
index 364597e..8d0a9f0 100644
--- a/src/Fluxera.Entity/DomainEvents/DomainEventHandlerBuilder.cs
+++ b/src/Fluxera.Entity/DomainEvents/DomainEventHandlerBuilder.cs
@@ -115,7 +115,7 @@ public DomainEventHandlerBuilder AddDomainEventHandlers(Type type)
}
///
- /// Adds the provided domain dispatcher service.
+ /// Adds the provided domain dispatcher service as scoped.
///
///
///
diff --git a/src/Fluxera.Entity/DomainEvents/ServiceCollectionExtensions.cs b/src/Fluxera.Entity/DomainEvents/ServiceCollectionExtensions.cs
index 35ea895..6bb10e7 100644
--- a/src/Fluxera.Entity/DomainEvents/ServiceCollectionExtensions.cs
+++ b/src/Fluxera.Entity/DomainEvents/ServiceCollectionExtensions.cs
@@ -13,7 +13,7 @@
public static class ServiceCollectionExtensions
{
///
- /// Adds the domain events services.
+ /// Adds the domain events services. The domain events dispatcher is register as scoped.
///
///
///
@@ -24,7 +24,7 @@ public static IServiceCollection AddDomainEvents(this IServiceCollection service
Guard.Against.Null(configureHandlers);
// Register domain event dispatcher.
- services.TryAddTransient();
+ services.AddDomainEventDispatcher();
// Configure the domain event handlers.
configureHandlers.Invoke(new DomainEventHandlerBuilder(services));
@@ -33,7 +33,7 @@ public static IServiceCollection AddDomainEvents(this IServiceCollection service
}
///
- /// Adds the provided domain dispatcher service.
+ /// Adds the provided domain dispatcher service as scoped.
///
///
///
@@ -42,7 +42,7 @@ public static IServiceCollection AddDomainEventDispatcher(this ISer
where TDispatcher : class, IDomainEventDispatcher
{
services.RemoveAll();
- services.AddTransient();
+ services.AddScoped();
return services;
}
diff --git a/src/Fluxera.Entity/PropertyAccessor.cs b/src/Fluxera.Entity/PropertyAccessor.cs
index ad7a73e..c2a7b87 100644
--- a/src/Fluxera.Entity/PropertyAccessor.cs
+++ b/src/Fluxera.Entity/PropertyAccessor.cs
@@ -1,4 +1,7 @@
-namespace Fluxera.Entity
+// ReSharper disable AssignNullToNotNullAttribute
+// ReSharper disable PossibleNullReferenceException
+
+namespace Fluxera.Entity
{
using System;
using System.Collections.Concurrent;