Hey @alien, if you’re using .NET Core’s builtin DI then you can do it like this:
-
Register the class/interface service in Startup.cs (web) or Program.cs (console):
services.AddTransient<SomeDependencyClass>();
Note: change service lifetime to scoped or singleton as per your needs.
-
Register filter instance with dependency in Program.cs (required for console app only; not required for web):
services.AddHangfire((provider, config) => config.UseFilter(new MyFilterAttribute(provider.GetService<SomeDependencyClass>())));
Hope it helps.