public MvcOptionsSetup(ILoggerFactory loggerFactory, IOptions <MvcJilOptions> jilOptions) { if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (jilOptions == null) { throw new ArgumentNullException(nameof(jilOptions)); } _loggerFactory = loggerFactory; _serializerSettings = jilOptions.Value.SerializerSettings; }
public static IMvcBuilder WithJsonFormattersBasedOnJil( this IMvcBuilder builder, global::Jil.Options serializerSettings) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder.Services.AddSingleton(Options.Create(new MvcJilOptions { SerializerSettings = serializerSettings })); builder.Services.TryAddEnumerable(ServiceDescriptor.Transient <IConfigureOptions <MvcOptions>, MvcOptionsSetup>()); return(builder); }