public static JsonSerializerSettings WithPrivateSetterContractResolver( this JsonSerializerSettings settings, ConstructorHandling constructorHandling = ConstructorHandling.Default) { settings.ConstructorHandling = constructorHandling; settings.ContractResolver = new PrivateSetterResolver(); return(settings); }
/// <summary> /// Initializes a new instance of the <see cref="JsonSerializer"/> class. /// </summary> public JsonSerializer() { _referenceLoopHandling = JsonSerializerSettings.DefaultReferenceLoopHandling; _missingMemberHandling = JsonSerializerSettings.DefaultMissingMemberHandling; _nullValueHandling = JsonSerializerSettings.DefaultNullValueHandling; _defaultValueHandling = JsonSerializerSettings.DefaultDefaultValueHandling; _objectCreationHandling = JsonSerializerSettings.DefaultObjectCreationHandling; _preserveReferencesHandling = JsonSerializerSettings.DefaultPreserveReferencesHandling; _constructorHandling = JsonSerializerSettings.DefaultConstructorHandling; _typeNameHandling = JsonSerializerSettings.DefaultTypeNameHandling; _binder = DefaultSerializationBinder.Instance; }
public JsonSerializer() { this._referenceLoopHandling = ReferenceLoopHandling.Error; this._missingMemberHandling = MissingMemberHandling.Ignore; this._nullValueHandling = NullValueHandling.Include; this._defaultValueHandling = DefaultValueHandling.Include; this._objectCreationHandling = ObjectCreationHandling.Auto; this._preserveReferencesHandling = PreserveReferencesHandling.None; this._constructorHandling = ConstructorHandling.Default; this._typeNameHandling = TypeNameHandling.None; this._context = JsonSerializerSettings.DefaultContext; this._binder = (SerializationBinder)DefaultSerializationBinder.Instance; }
/// <summary> /// Tests the ConstructorHandling property in a JSON serializer settings object. /// </summary> /// <param name="constructorHandling">Expected ConstructorHandling.</param> /// <returns>The same JSON serializer settings test builder.</returns> public IAndJsonSerializerSettingsTestBuilder WithConstructorHandling(ConstructorHandling constructorHandling) { this.jsonSerializerSettings.ConstructorHandling = constructorHandling; this.validations.Add((expected, actual) => { if (!CommonValidator.CheckEquality(expected.ConstructorHandling, actual.ConstructorHandling)) { this.ThrowNewJsonResultAssertionException( string.Format("{0} constructor handling", expected.ConstructorHandling), string.Format("in fact found {0}", actual.ConstructorHandling)); } }); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="JsonSerializer"/> class. /// </summary> public JsonSerializer() { _referenceLoopHandling = JsonSerializerSettings.DefaultReferenceLoopHandling; _missingMemberHandling = JsonSerializerSettings.DefaultMissingMemberHandling; _nullValueHandling = JsonSerializerSettings.DefaultNullValueHandling; _defaultValueHandling = JsonSerializerSettings.DefaultDefaultValueHandling; _objectCreationHandling = JsonSerializerSettings.DefaultObjectCreationHandling; _preserveReferencesHandling = JsonSerializerSettings.DefaultPreserveReferencesHandling; _constructorHandling = JsonSerializerSettings.DefaultConstructorHandling; _typeNameHandling = JsonSerializerSettings.DefaultTypeNameHandling; _metadataPropertyHandling = JsonSerializerSettings.DefaultMetadataPropertyHandling; _context = JsonSerializerSettings.DefaultContext; _binder = DefaultSerializationBinder.Instance; _culture = JsonSerializerSettings.DefaultCulture; _contractResolver = DefaultContractResolver.Instance; }