Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Have to register the Command Processor as scoped #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Henderson committed Dec 19, 2018
1 parent aa0dba3 commit 5adc6b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void ShouldHaveRegistered12Correctly()
[Fact]
public void ShouldHaveCommandProcessorRegisteredCorrectly()
{
TestRegistration(typeof(IAmACommandProcessor), ServiceLifetime.Singleton);
TestRegistration(typeof(IAmACommandProcessor), ServiceLifetime.Scoped);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public static IBrighterHandlerBuilder AddBrighter(this IServiceCollection servic
var subscriberRegistry = new ServiceCollectionSubscriberRegistry(services, options.HandlerLifetime);
services.AddSingleton<ServiceCollectionSubscriberRegistry>(subscriberRegistry);

services.AddSingleton<IAmACommandProcessor>(BuildCommandProcessor);
if (options.HandlerLifetime == ServiceLifetime.Scoped)
services.AddScoped<IAmACommandProcessor>(BuildCommandProcessor);
else
services.AddSingleton<IAmACommandProcessor>(BuildCommandProcessor);

return new ServiceCollectionBrighterBuilder(services, subscriberRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public static IServiceActivatorBuilder AddServiceActivator(
var subscriberRegistry = new ServiceCollectionSubscriberRegistry(services, options.HandlerLifetime);
services.AddSingleton<ServiceCollectionSubscriberRegistry>(subscriberRegistry);

services.AddSingleton<IAmACommandProcessor>(BuildCommandProcessor);
if (options.HandlerLifetime == ServiceLifetime.Scoped)
services.AddScoped<IAmACommandProcessor>(BuildCommandProcessor);
else
services.AddSingleton<IAmACommandProcessor>(BuildCommandProcessor);

var mapperRegistry = new ServiceCollectionMessageMapperRegistry(services, options.MapperLifetime);
services.AddSingleton<ServiceCollectionMessageMapperRegistry>(mapperRegistry);
Expand Down

0 comments on commit 5adc6b2

Please sign in to comment.