I am using MVC with Autofac. I would like to register an action that runs once to launch the application. I would like to achieve this. eg:
public class SomeModule : IOnceRunnable
{
private IService service;
public SomeModule(IService service)
{
this.service = service;
}
public void Action()
{
}
}
containerBuilder.RegisterOnceRunnable<SomeModule>();
Can I do this?
I know that I can use the built-in container ( var container = builder.Build();<- allow manual services), but maybe there is a more "elegant" solution like the one above.
user2160375
source
share