diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs
index 269d1cfcbe..1dee621091 100644
--- a/src/Umbraco.Core/CoreBootManager.cs
+++ b/src/Umbraco.Core/CoreBootManager.cs
@@ -471,48 +471,5 @@ namespace Umbraco.Core
PublishedContentModelFactoryResolver.Current = new PublishedContentModelFactoryResolver(Container);
}
- /////
- ///// An IoC lifetime that will dispose instances at the end of the bootup sequence
- /////
- //private class BootManagerLifetime : ILifetime
- //{
- // public BootManagerLifetime(UmbracoApplicationBase appBase)
- // {
- // appBase.ApplicationStarted += appBase_ApplicationStarted;
- // }
-
- // void appBase_ApplicationStarted(object sender, EventArgs e)
- // {
- // throw new NotImplementedException();
- // }
-
- // private object _instance;
-
- // ///
- // /// Returns a service instance according to the specific lifetime characteristics.
- // ///
- // /// The function delegate used to create a new service instance.
- // /// The of the current service request.
- // /// The requested services instance.
- // public object GetInstance(Func createInstance, Scope scope)
- // {
- // if (_instance == null)
- // {
- // _instance = createInstance();
-
- // var disposable = _instance as IDisposable;
- // if (disposable != null)
- // {
- // if (scope == null)
- // {
- // throw new InvalidOperationException("Attempt to create an disposable object without a current scope.");
- // }
- // scope.TrackInstance(disposable);
- // }
-
- // }
- // return createInstance;
- // }
- //}
}
}
diff --git a/src/Umbraco.Core/DependencyInjection/RepositoryCompositionRoot.cs b/src/Umbraco.Core/DependencyInjection/RepositoryCompositionRoot.cs
index fed06943f3..2f3657991d 100644
--- a/src/Umbraco.Core/DependencyInjection/RepositoryCompositionRoot.cs
+++ b/src/Umbraco.Core/DependencyInjection/RepositoryCompositionRoot.cs
@@ -138,19 +138,19 @@ namespace Umbraco.Core.DependencyInjection
factory.GetInstance(),
factory.GetInstance(),
factory.GetInstance()));
- container.Register((factory, work) => new ScriptRepository(
+ container.Register((factory, work) => new ScriptRepository(
work,
factory.GetInstance("ScriptFileSystem"),
factory.GetInstance()));
- container.Register((factory, work) => new PartialViewRepository(
+ container.Register((factory, work) => new PartialViewRepository(
work,
factory.GetInstance("ScriptFileSystem")),
serviceName: "PartialViewFileSystem");
- container.Register((factory, work) => new PartialViewMacroRepository(
+ container.Register((factory, work) => new PartialViewMacroRepository(
work,
factory.GetInstance("PartialViewMacroFileSystem")),
serviceName: "PartialViewMacroRepository");
- container.Register((factory, work) => new StylesheetRepository(
+ container.Register((factory, work) => new StylesheetRepository(
work,
factory.GetInstance("StylesheetFileSystem")));
container.Register((factory, work) => new TemplateRepository(
diff --git a/src/Umbraco.Core/Persistence/RepositoryFactory.cs b/src/Umbraco.Core/Persistence/RepositoryFactory.cs
index 2b82490457..6735e3e778 100644
--- a/src/Umbraco.Core/Persistence/RepositoryFactory.cs
+++ b/src/Umbraco.Core/Persistence/RepositoryFactory.cs
@@ -123,7 +123,7 @@ namespace Umbraco.Core.Persistence
public virtual ITemplateRepository CreateTemplateRepository(IDatabaseUnitOfWork uow)
{
- return _container.GetInstance(uow);
+ return _container.GetInstance(uow);
}
public virtual IMigrationEntryRepository CreateMigrationEntryRepository(IDatabaseUnitOfWork uow)
diff --git a/src/Umbraco.Web/DefaultUmbracoContextAccessor.cs b/src/Umbraco.Web/DefaultUmbracoContextAccessor.cs
index 1e413429a1..3bd7d5f95b 100644
--- a/src/Umbraco.Web/DefaultUmbracoContextAccessor.cs
+++ b/src/Umbraco.Web/DefaultUmbracoContextAccessor.cs
@@ -1,17 +1,19 @@
+using System;
+
namespace Umbraco.Web
{
internal class DefaultUmbracoContextAccessor : IUmbracoContextAccessor
{
- private readonly UmbracoContext _umbracoContext;
+ private readonly Func _umbracoContext;
- public DefaultUmbracoContextAccessor(UmbracoContext umbracoContext)
+ public DefaultUmbracoContextAccessor(Func umbracoContext)
{
_umbracoContext = umbracoContext;
}
public UmbracoContext Value
{
- get { return _umbracoContext; }
+ get { return _umbracoContext(); }
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs
index 3d2dbcfb7e..e996d2e46c 100644
--- a/src/Umbraco.Web/WebBootManager.cs
+++ b/src/Umbraco.Web/WebBootManager.cs
@@ -314,6 +314,15 @@ namespace Umbraco.Web
{
base.ConfigureCoreServices(container);
+ container.EnablePerWebRequestScope();
+
+ container.Register(new PerContainerLifetime());
+ //TODO: Is this lifespan correct? Need to ask Stephen because we have contextual ones too
+ container.Register(new PerContainerLifetime());
+ container.Register(new PerContainerLifetime());
+ //no need to declare as per request, currently we manage it's lifetime as the singleton
+ container.Register(factory => UmbracoContext.Current);
+
//Replace services:
container.Register();
}
@@ -328,18 +337,9 @@ namespace Umbraco.Web
//IoC setup for LightInject for mvc/webapi
Container.EnableMvc();
- Container.RegisterMvcControllers(PluginManager);
- container.EnablePerWebRequestScope();
+ Container.RegisterMvcControllers(PluginManager);
container.EnableWebApi(GlobalConfiguration.Configuration);
container.RegisterApiControllers(PluginManager);
-
- //register other services
- container.Register(new PerRequestLifeTime());
- //TODO: Is this lifespan correct? Need to ask Stephen because we have contextual ones too
- container.Register(new PerContainerLifetime());
- container.Register(new PerContainerLifetime());
- //no need to declare as per request, currently we manage it's lifetime as the singleton
- container.Register(factory => UmbracoContext.Current);
}
///