Created
August 29, 2018 11:49
-
-
Save jrunestone/9a5c89c2b472ea6067bf2391a96854cf to your computer and use it in GitHub Desktop.
Inject site settings with Structuremap in Episerver
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
[InitializableModule] | |
public class DependencyInstaller : IConfigurableModule | |
{ | |
public void ConfigureContainer(ServiceConfigurationContext context) | |
{ | |
var container = context.StructureMap(); | |
DependencyResolver.SetResolver(new StructureMapDependencyResolver(container)); | |
context.Services.Add<SiteSettings>(sl => | |
{ | |
var factory = sl.GetInstance<ViewModelFactory>(); | |
return factory.SiteSettings; | |
}, ServiceInstanceScope.HttpContext); | |
} | |
public void Initialize(InitializationEngine context) | |
{ | |
} | |
public void Uninitialize(InitializationEngine context) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment