Skip to content

Commit

Permalink
Improve handling of root container creation
Browse files Browse the repository at this point in the history
  • Loading branch information
generik0 committed Jul 8, 2020
1 parent 70dd700 commit b536e58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class WindsorServiceProviderFactory : WindsorServiceProviderFactor
{
public WindsorServiceProviderFactory()
{
CreateContainer();
CreateRootContainer();
CreateRootScope();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected virtual void CreateRootScope()
rootScope = ExtensionContainerRootScope.BeginRootScope();
}

protected virtual void CreateContainer()
protected virtual void CreateRootContainer()
{
rootContainer = new WindsorContainer();
rootContainer.Kernel.AddSubSystem(
Expand All @@ -58,6 +58,12 @@ protected virtual void CreateContainer()

protected virtual IWindsorContainer BuildContainer(IServiceCollection serviceCollection, WindsorContainer windsorContainer)
{
if (rootContainer == null)
{
CreateRootContainer();
}
if (rootContainer == null) throw new ArgumentNullException("Could not initialize container");

if (serviceCollection == null)
{
return rootContainer;
Expand Down

0 comments on commit b536e58

Please sign in to comment.