예제 #1
0
 public JsonRepositorySerializer(ModelObjectContractCache modelObjectContractCache, ModelObjectSpecialValueProvider specialValueProvider,
                                 ModelObjectSerializationContext context = null)
 {
     _specialValueProvider = specialValueProvider ?? throw new ArgumentNullException(nameof(specialValueProvider));
     _serializer           = new JsonSerializer
     {
         NullValueHandling     = NullValueHandling.Ignore,
         ContractResolver      = CreateContractResolver(modelObjectContractCache, context),
         TypeNameHandling      = TypeNameHandling.Objects,
         SerializationBinder   = NetCoreSerializationBinder.Instance,
         ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
         Formatting            = Formatting.Indented,
         DefaultValueHandling  = DefaultValueHandling.IgnoreAndPopulate,
     };
     _serializer.Converters.Add(new VersionConverter());
 }
예제 #2
0
 private static CamelCasePropertyNamesContractResolver CreateContractResolver(ModelObjectContractCache modelObjectContractCache, ModelObjectSerializationContext context) =>
 context != null ? new ModelObjectContractResolver(context, modelObjectContractCache) : new CamelCasePropertyNamesContractResolver();