Created
February 6, 2014 10:22
-
-
Save leethomascook/8841684 to your computer and use it in GitHub Desktop.
StructureMap and umbraco 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Global.asax | |
protected override void OnApplicationStarting(object sender, EventArgs e) | |
{ | |
base.OnApplicationStarting(sender, e); | |
ObjectFactory.Configure( | |
x => x.For<ITest>().Use<Test>() | |
); | |
FilteredControllerFactoriesResolver.Current.RemoveType<RenderControllerFactory>(); | |
FilteredControllerFactoriesResolver.Current.AddType<CustomControllerFactory>(); | |
} | |
------------ | |
public class CustomControllerFactory : RenderControllerFactory | |
{ | |
public override Type GetControllerType(RequestContext requestContext, string controllerName) | |
{ | |
return base.GetControllerType(requestContext, controllerName); | |
} | |
public override IController CreateController(RequestContext requestContext, string controllerName) | |
{ | |
var type = base.GetControllerType(requestContext, controllerName); | |
return ObjectFactory.GetInstance(type) as Controller; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment