From c343f6d4353db6a5800faeac9a2c3814ff65357d Mon Sep 17 00:00:00 2001 From: Rikard Pavelic Date: Wed, 12 Nov 2014 22:44:01 +0100 Subject: [PATCH] Changes to Revenj.Core Root container should have all registrations. Unit of work was missing this keyword. --- .../Revenj.Core/AutofacConfiguration.cs | 28 ++++++++++++++----- Code/Server/Revenj.Core/UnitOfWork.cs | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Code/Server/Revenj.Core/AutofacConfiguration.cs b/Code/Server/Revenj.Core/AutofacConfiguration.cs index c5d713006..9c3d9fd99 100644 --- a/Code/Server/Revenj.Core/AutofacConfiguration.cs +++ b/Code/Server/Revenj.Core/AutofacConfiguration.cs @@ -43,18 +43,32 @@ public static IServiceLocator Configure(Database database, string connectionStri builder.RegisterType().As().SingleInstance(); builder.RegisterType().As(); - var container = builder.Build(); - var init = container.Resolve(); - init.Initialize(false); - var factory = container.Resolve(); - //TODO init model - factory.Resolve(); + builder.RegisterType().As(); + + var factory = builder.Build().Resolve(); state.IsBooting = false; state.Started(factory); - return factory.Resolve(); } + class OnContainerBuild : Autofac.IStartable + { + private readonly IObjectFactory Factory; + + public OnContainerBuild(IObjectFactory factory) + { + this.Factory = factory; + } + + public void Start() + { + var init = Factory.Resolve(); + init.Initialize(false); + //TODO change domain model boot. export to ISystemAspect to avoid explicit initialization + Factory.Resolve(); + } + } + class AspectsModule : Autofac.Module { private readonly AspectRepository Repository; diff --git a/Code/Server/Revenj.Core/UnitOfWork.cs b/Code/Server/Revenj.Core/UnitOfWork.cs index 1f60ca578..01d1db265 100644 --- a/Code/Server/Revenj.Core/UnitOfWork.cs +++ b/Code/Server/Revenj.Core/UnitOfWork.cs @@ -155,7 +155,7 @@ public static class LocatorHelper /// /// service locator /// unit of work - public static IUnitOfWork DoWork(IServiceLocator locator) + public static IUnitOfWork DoWork(this IServiceLocator locator) { return new UnitOfWork(locator.Resolve()); }