Skip to content

Commit

Permalink
Changes to Revenj.Core
Browse files Browse the repository at this point in the history
Root container should have all registrations.
Unit of work was missing this keyword.
  • Loading branch information
zapov committed Nov 12, 2014
1 parent a52a930 commit c343f6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
28 changes: 21 additions & 7 deletions Code/Server/Revenj.Core/AutofacConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,32 @@ public static IServiceLocator Configure(Database database, string connectionStri
builder.RegisterType<LogFactory>().As<ILogFactory>().SingleInstance();
builder.RegisterType<NLogLogger>().As<ILogger>();

var container = builder.Build();
var init = container.Resolve<SystemInitialization>();
init.Initialize(false);
var factory = container.Resolve<IObjectFactory>();
//TODO init model
factory.Resolve<IDomainModel>();
builder.RegisterType<OnContainerBuild>().As<IStartable>();

var factory = builder.Build().Resolve<IObjectFactory>();
state.IsBooting = false;
state.Started(factory);

return factory.Resolve<IServiceLocator>();
}

class OnContainerBuild : Autofac.IStartable
{
private readonly IObjectFactory Factory;

public OnContainerBuild(IObjectFactory factory)
{
this.Factory = factory;
}

public void Start()
{
var init = Factory.Resolve<SystemInitialization>();
init.Initialize(false);
//TODO change domain model boot. export to ISystemAspect to avoid explicit initialization
Factory.Resolve<IDomainModel>();
}
}

class AspectsModule : Autofac.Module
{
private readonly AspectRepository Repository;
Expand Down
2 changes: 1 addition & 1 deletion Code/Server/Revenj.Core/UnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public static class LocatorHelper
/// </summary>
/// <param name="locator">service locator</param>
/// <returns>unit of work</returns>
public static IUnitOfWork DoWork(IServiceLocator locator)
public static IUnitOfWork DoWork(this IServiceLocator locator)
{
return new UnitOfWork(locator.Resolve<IObjectFactory>());
}
Expand Down

0 comments on commit c343f6d

Please sign in to comment.