Well, let me give you basic example,
- I have an interface that holds current user, call it IUserContext,
- I have two implementations, WebUserContext, HangfireUserContext.
- WebUserContext uses httpcontext.current.user and HangfireUserContext uses some static field, it does not matter.
- I have failed to find a way to discriminate contains of aspnet and hangfire.
The things I have tried:
- GlobalConfiguration.Configuration.UseActivator(new MyActivator(services));
Hangfire did not called my ActivateJob method. - app.UseHangfireServer(new BackgroundJobServerOptions()
{
Activator = new MyActivator(services)
});
Hangfire did not called my ActivateJob method.
In both examples, Hangfire uses default IoC container which is registered&used by asp.net core