Skip to content

Commit

Permalink
Merge branch 'feature-683' of https://github.com/simpleinjector/Simpl…
Browse files Browse the repository at this point in the history
…eInjector into v4.6.x
  • Loading branch information
dotnetjunkie committed May 10, 2019
2 parents 0e94ae7 + e1b2b82 commit fb979b5
Showing 1 changed file with 11 additions and 1 deletion.
Expand Up @@ -339,10 +339,16 @@ private static void CrossWireServiceScope(Container container, IServiceProvider
private static Registration CreateSingletonRegistration(
Container container, Type serviceType, IServiceProvider appServices)
{
return Lifestyle.Singleton.CreateRegistration(
var registration = Lifestyle.Singleton.CreateRegistration(
serviceType,
() => appServices.GetRequiredService(serviceType),
container);

// This registration is managed and disposed by IServiceProvider and should, therefore, not be
// disposed (again) by Simple Injector.
registration.SuppressDisposal = true;

return registration;
}

private static Registration CreateNonSingletonRegistration(
Expand All @@ -355,6 +361,10 @@ private static void CrossWireServiceScope(Container container, IServiceProvider
() => GetServiceProvider(accessor, container, lifestyle).GetRequiredService(serviceType),
container);

// This registration is managed and disposed by IServiceProvider and should, therefore, not be
// disposed (again) by Simple Injector.
registration.SuppressDisposal = true;

if (lifestyle == Lifestyle.Transient && typeof(IDisposable).IsAssignableFrom(serviceType))
{
registration.SuppressDiagnosticWarning(
Expand Down

0 comments on commit fb979b5

Please sign in to comment.