codeyu / Hangfire.LiteDB

LiteDB storage for Hangfire.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Json serialization settings ignored

MauroMon opened this issue · comments

Hello.

Use hangifre with liteDb ignore the json serialization settings applied in GlobalConfiguration;

.UseSerializerSettings(new JsonSerializerSettings() {

In my particular case i have a self refering loop that needs to be ignored so i tried this:

image

but obviulsy is not working since the settings are rewritten.

is there a way to solve this problem?

This is a sample project that simulate my problem:

https://github.com/MauroMon/HangfireSerializationSettings.git

Thanks for your help

This is a workaround, but is not the best:

GlobalConfiguration.Configuration
                    .UseActivator(new HangfireJobActivator())
                    .UseFilter(filter)
                    .UseLog4NetLogProvider()
                    .LiteDbStorage("hangfire.db");

               GlobalConfiguration.Configuration
              .UseSerializerSettings(new JsonSerializerSettings()
              {
                  ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                  TypeNameHandling = TypeNameHandling.Objects,
                  DateTimeZoneHandling = DateTimeZoneHandling.Utc,
                  DateFormatHandling = DateFormatHandling.IsoDateFormat,
                  DateFormatString = "yyyy-MM-dd HH:mm:ss.fff"
              });