#18282: Resolving WorkContext the correct way in ShapeTracing

Work Item: 18282

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-12-29 16:13:52 -08:00
parent 72e5883fdd
commit 076b73f267
3 changed files with 4 additions and 5 deletions
@@ -24,13 +24,13 @@ namespace Orchard.DesignerTools.Services {
private int _shapeId; private int _shapeId;
public ShapeTracingFactory( public ShapeTracingFactory(
WorkContext workContext, IWorkContextAccessor workContextAccessor,
IShapeTableManager shapeTableManager, IShapeTableManager shapeTableManager,
IThemeManager themeManager, IThemeManager themeManager,
IWebSiteFolder webSiteFolder, IWebSiteFolder webSiteFolder,
IAuthorizer authorizer IAuthorizer authorizer
) { ) {
_workContext = workContext; _workContext = workContextAccessor.GetContext();
_shapeTableManager = shapeTableManager; _shapeTableManager = shapeTableManager;
_themeManager = themeManager; _themeManager = themeManager;
_webSiteFolder = webSiteFolder; _webSiteFolder = webSiteFolder;
@@ -20,7 +20,7 @@ namespace Orchard.Environment {
IHttpContextAccessor httpContextAccessor, IHttpContextAccessor httpContextAccessor,
ILifetimeScope lifetimeScope) { ILifetimeScope lifetimeScope) {
_httpContextAccessor = httpContextAccessor; _httpContextAccessor = httpContextAccessor;
_lifetimeScope = lifetimeScope; _lifetimeScope = lifetimeScope.Resolve<ILifetimeScope>();
} }
public WorkContext GetContext(HttpContextBase httpContext) { public WorkContext GetContext(HttpContextBase httpContext) {
+1 -2
View File
@@ -7,13 +7,12 @@ using Autofac;
using Autofac.Builder; using Autofac.Builder;
using Autofac.Core; using Autofac.Core;
using Autofac.Features.Metadata; using Autofac.Features.Metadata;
using Orchard.Mvc;
using Module = Autofac.Module; using Module = Autofac.Module;
namespace Orchard.Environment { namespace Orchard.Environment {
public class WorkContextModule : Module { public class WorkContextModule : Module {
protected override void Load(ContainerBuilder builder) { protected override void Load(ContainerBuilder builder) {
builder.Register(ctx => new WorkContextAccessor(ctx.Resolve<IHttpContextAccessor>(), ctx.Resolve<ILifetimeScope>())) builder.RegisterType<WorkContextAccessor>()
.As<IWorkContextAccessor>() .As<IWorkContextAccessor>()
.InstancePerMatchingLifetimeScope("shell"); .InstancePerMatchingLifetimeScope("shell");