I wan't to add some configuration to hangfire. It's easy going the documented way but there is one option that depends on User setting so I wan't to do it like this:
IGlobalConfiguration hangfireConfiguration = GlobalConfiguration.Configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings();
if (Configuration.GetValue<bool>("HangfireUseMemoryStorage"))
{
hangfireConfiguration.UseMemoryStorage();
}
else
{
hangfireConfiguration.UseStorage(new MySqlStorage(
Configuration.GetConnectionString("DefaultConnection"),
new MySqlStorageOptions
{
TablesPrefix = "Hangfire"
})
);
};
But how to add a service with this configuration? Trying
services.AddHangfire(hangfireConfiguration);
leads to
cannot convert from 'Hangfire.IGlobalConfiguration' to 'System.Action<Hangfire.IGlobalConfiguration>'
So how can I add my configuration?