I have several WebActivator.PreApplicationStartMethod decorated classes.
One is for Ninject, another class for AwesomeMVC and a third one is for background task scheduler.
The problem is that the scheduler class needs to take advantage of the dependecies, that are resolved by IoC container.
My questions are:
- Can I have several WebActivator.PreApplicationStartMethod classes?
- Can I define order, in which they are initialized, so that IoC, being the most important, comes first?
- Can WebActivator.PreApplicationStartMethod static class instances rely on IoC container to resolve their constructor-defined dependencies?
If you know that PreAppStart method A needs to run after PreAppStart method B, then the only way to achive that is to explicitly add a call to B inside the body of A.
For that strategy to work correctly you should also make sure that your PreAppStart method implementations are indempotent i.e. they can safely be called multiple times. Usually this can be achieved by keeping track of whether the method has already been called in a static boolean variable and not doing anything if that vale is true.