Skip to content

Instantly share code, notes, and snippets.

@jrunestone
Created August 29, 2018 11:49
Show Gist options
  • Save jrunestone/9a5c89c2b472ea6067bf2391a96854cf to your computer and use it in GitHub Desktop.
Save jrunestone/9a5c89c2b472ea6067bf2391a96854cf to your computer and use it in GitHub Desktop.
Inject site settings with Structuremap in Episerver
[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