public JsonSerializerProxy(JsonSerializerInternalWriter serializerWriter) { ValidationUtils.ArgumentNotNull(serializerWriter, "serializerWriter"); _serializerWriter = serializerWriter; _serializer = serializerWriter.Serializer; }
internal virtual void SerializeInternal(JsonWriter jsonWriter, object value) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); JsonSerializerInternalWriter jsonSerializerInternalWriter = new JsonSerializerInternalWriter(this); jsonSerializerInternalWriter.Serialize(jsonWriter, value); }
/// <summary> /// Writes the JSON representation of the object. /// </summary> /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> /// <param name="value">The value.</param> /// <param name="serializer">The calling serializer.</param> public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver; IEntityKeyMember entityKeyMember = DynamicWrapper.CreateWrapper <IEntityKeyMember>(value); Type keyType = (entityKeyMember.Value != null) ? entityKeyMember.Value.GetType() : null; writer.WriteStartObject(); writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(KeyPropertyName) : KeyPropertyName); writer.WriteValue(entityKeyMember.Key); writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(TypePropertyName) : TypePropertyName); writer.WriteValue((keyType != null) ? keyType.FullName : null); writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(ValuePropertyName) : ValuePropertyName); if (keyType != null) { string valueJson; if (JsonSerializerInternalWriter.TryConvertToString(entityKeyMember.Value, keyType, out valueJson)) { writer.WriteValue(valueJson); } else { writer.WriteValue(entityKeyMember.Value); } } else { writer.WriteNull(); } writer.WriteEndObject(); }
internal virtual void SerializeInternal(JsonWriter jsonWriter, object value, bool useDefaultFormat = true) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); JsonSerializerInternalWriter serializerWriter = new JsonSerializerInternalWriter(this, useDefaultFormat); serializerWriter.Serialize(jsonWriter, value, useDefaultFormat); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { string str; Type type; string fullName; EntityKeyMemberConverter.EnsureReflectionObject(value.GetType()); DefaultContractResolver contractResolver = serializer.ContractResolver as DefaultContractResolver; string str1 = (string)EntityKeyMemberConverter._reflectionObject.GetValue(value, "Key"); object obj = EntityKeyMemberConverter._reflectionObject.GetValue(value, "Value"); if (obj != null) { type = obj.GetType(); } else { type = null; } Type type1 = type; writer.WriteStartObject(); writer.WritePropertyName((contractResolver != null ? contractResolver.GetResolvedPropertyName("Key") : "Key")); writer.WriteValue(str1); writer.WritePropertyName((contractResolver != null ? contractResolver.GetResolvedPropertyName("Type") : "Type")); JsonWriter jsonWriter = writer; if (type1 != null) { fullName = type1.FullName; } else { fullName = null; } jsonWriter.WriteValue(fullName); writer.WritePropertyName((contractResolver != null ? contractResolver.GetResolvedPropertyName("Value") : "Value")); if (type1 == null) { writer.WriteNull(); } else if (!JsonSerializerInternalWriter.TryConvertToString(obj, type1, out str)) { writer.WriteValue(obj); } else { writer.WriteValue(str); } writer.WriteEndObject(); }
internal virtual void SerializeInternal(JsonWriter jsonWriter, object value) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); // set serialization options onto writer Formatting?previousFormatting = null; if (_formatting != null && jsonWriter.Formatting != _formatting) { previousFormatting = jsonWriter.Formatting; jsonWriter.Formatting = _formatting.Value; } DateFormatHandling?previousDateFormatHandling = null; if (_dateFormatHandling != null && jsonWriter.DateFormatHandling != _dateFormatHandling) { previousDateFormatHandling = jsonWriter.DateFormatHandling; jsonWriter.DateFormatHandling = _dateFormatHandling.Value; } DateTimeZoneHandling?previousDateTimeZoneHandling = null; if (_dateTimeZoneHandling != null && jsonWriter.DateTimeZoneHandling != _dateTimeZoneHandling) { previousDateTimeZoneHandling = jsonWriter.DateTimeZoneHandling; jsonWriter.DateTimeZoneHandling = _dateTimeZoneHandling.Value; } JsonSerializerInternalWriter serializerWriter = new JsonSerializerInternalWriter(this); serializerWriter.Serialize(jsonWriter, value); // reset writer back to previous options if (previousFormatting != null) { jsonWriter.Formatting = previousFormatting.Value; } if (previousDateFormatHandling != null) { jsonWriter.DateFormatHandling = previousDateFormatHandling.Value; } if (previousDateTimeZoneHandling != null) { jsonWriter.DateTimeZoneHandling = previousDateTimeZoneHandling.Value; } }
/// <summary> /// Writes the JSON representation of the object. /// </summary> /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> /// <param name="value">The value.</param> /// <param name="serializer">The calling serializer.</param> public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (value == null) { writer.WriteNull(); return; } EnsureReflectionObject(value.GetType()); MiscellaneousUtils.Assert(_reflectionObject != null); DefaultContractResolver resolver = serializer.ContractResolver as DefaultContractResolver; string keyName = (string)_reflectionObject.GetValue(value, KeyPropertyName); object keyValue = _reflectionObject.GetValue(value, ValuePropertyName); Type keyValueType = keyValue?.GetType(); writer.WriteStartObject(); writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(KeyPropertyName) : KeyPropertyName); writer.WriteValue(keyName); writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(TypePropertyName) : TypePropertyName); writer.WriteValue(keyValueType?.FullName); writer.WritePropertyName((resolver != null) ? resolver.GetResolvedPropertyName(ValuePropertyName) : ValuePropertyName); if (keyValueType != null) { if (JsonSerializerInternalWriter.TryConvertToString(keyValue, keyValueType, out string valueJson)) { writer.WriteValue(valueJson); } else { writer.WriteValue(keyValue); } } else { writer.WriteNull(); } writer.WriteEndObject(); }
public SerializerCache(JsonSerializerSettings settings) { JsonSerializer = Newtonsoft.Json.JsonSerializer.CreateDefault(settings); JsonSerializer.Formatting = Formatting.Indented; StringBuilder = new StringBuilder(256); StringWriter = new StringWriter(StringBuilder, CultureInfo.InvariantCulture); SerializerWriter = new JsonSerializerInternalWriter(JsonSerializer); StringReader = new UnmanagedStringReader(); JsonWriter = new JsonTextWriter(StringWriter) { IndentChar = '\t', Indentation = 1, Formatting = JsonSerializer.Formatting, DateFormatHandling = JsonSerializer.DateFormatHandling, DateTimeZoneHandling = JsonSerializer.DateTimeZoneHandling, FloatFormatHandling = JsonSerializer.FloatFormatHandling, StringEscapeHandling = JsonSerializer.StringEscapeHandling, Culture = JsonSerializer.Culture, DateFormatString = JsonSerializer.DateFormatString, }; }
public unsafe SerializerCache(JsonSerializerSettings settings) { JsonSerializer = Newtonsoft.Json.JsonSerializer.CreateDefault(settings); JsonSerializer.Formatting = Formatting.Indented; StringBuilder = new StringBuilder(256); StringWriter = new StringWriter(StringBuilder, CultureInfo.InvariantCulture); SerializerWriter = new JsonSerializerInternalWriter(JsonSerializer); MemoryStream = new UnmanagedMemoryStream((byte *)0, 0); Reader = new StreamReader(MemoryStream, Encoding.UTF8, false); JsonWriter = new JsonTextWriter(StringWriter) { IndentChar = '\t', Indentation = 1, Formatting = JsonSerializer.Formatting, DateFormatHandling = JsonSerializer.DateFormatHandling, DateTimeZoneHandling = JsonSerializer.DateTimeZoneHandling, FloatFormatHandling = JsonSerializer.FloatFormatHandling, StringEscapeHandling = JsonSerializer.StringEscapeHandling, Culture = JsonSerializer.Culture, DateFormatString = JsonSerializer.DateFormatString, }; }
/// <summary> /// Writes the JSON representation of the object. /// </summary> /// <param name="writer">The <see cref="JsonWriter" /> to write to.</param> /// <param name="value">The value.</param> /// <param name="serializer">The calling serializer.</param> public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { EnsureReflectionObject(value.GetType()); var resolver = serializer.ContractResolver as DefaultContractResolver; var keyName = (string)_reflectionObject.GetValue(value, KeyPropertyName); var keyValue = _reflectionObject.GetValue(value, ValuePropertyName); var keyValueType = keyValue?.GetType(); writer.WriteStartObject(); writer.WritePropertyName(resolver != null ? resolver.GetResolvedPropertyName(KeyPropertyName) : KeyPropertyName); writer.WriteValue(keyName); writer.WritePropertyName(resolver != null ? resolver.GetResolvedPropertyName(TypePropertyName) : TypePropertyName); writer.WriteValue(keyValueType?.FullName); writer.WritePropertyName(resolver != null ? resolver.GetResolvedPropertyName(ValuePropertyName) : ValuePropertyName); if (keyValueType != null) { string valueJson; if (JsonSerializerInternalWriter.TryConvertToString(keyValue, keyValueType, out valueJson)) { writer.WriteValue(valueJson); } else { writer.WriteValue(keyValue); } } else { writer.WriteNull(); } writer.WriteEndObject(); }
// Token: 0x060014A5 RID: 5285 RVA: 0x0006DB84 File Offset: 0x0006BD84 public override void WriteJson(JsonWriter writer, [Nullable(2)] object value, JsonSerializer serializer) { if (value == null) { writer.WriteNull(); return; } EntityKeyMemberConverter.EnsureReflectionObject(value.GetType()); DefaultContractResolver defaultContractResolver = serializer.ContractResolver as DefaultContractResolver; string value2 = (string)EntityKeyMemberConverter._reflectionObject.GetValue(value, "Key"); object value3 = EntityKeyMemberConverter._reflectionObject.GetValue(value, "Value"); Type type = (value3 != null) ? value3.GetType() : null; writer.WriteStartObject(); writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Key") : "Key"); writer.WriteValue(value2); writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Type") : "Type"); writer.WriteValue((type != null) ? type.FullName : null); writer.WritePropertyName((defaultContractResolver != null) ? defaultContractResolver.GetResolvedPropertyName("Value") : "Value"); if (type != null) { string value4; if (JsonSerializerInternalWriter.TryConvertToString(value3, type, out value4)) { writer.WriteValue(value4); } else { writer.WriteValue(value3); } } else { writer.WriteNull(); } writer.WriteEndObject(); }
/// <summary> /// Writes the JSON representation of the object. /// </summary> /// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> /// <param name="value">The value.</param> /// <param name="serializer">The calling serializer.</param> public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { try { IEntityKeyMember entityKeyMember = DynamicWrapper.CreateWrapper <IEntityKeyMember>(value); Type keyType = (entityKeyMember.Value != null) ? entityKeyMember.Value.GetType() : null; writer.WriteStartObject(); writer.WritePropertyName("Key"); writer.WriteValue(entityKeyMember.Key); writer.WritePropertyName("Type"); writer.WriteValue((keyType != null) ? keyType.FullName : null); writer.WritePropertyName("Value"); if (keyType != null) { string valueJson; if (JsonSerializerInternalWriter.TryConvertToString(entityKeyMember.Value, keyType, out valueJson)) { writer.WriteValue(valueJson); } else { writer.WriteValue(entityKeyMember.Value); } } else { writer.WriteNull(); } writer.WriteEndObject(); } catch { } }
internal virtual void SerializeInternal(JsonWriter jsonWriter, object value, Type objectType) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); // set serialization options onto writer Formatting?previousFormatting = null; if (_formatting != null && jsonWriter.Formatting != _formatting) { previousFormatting = jsonWriter.Formatting; jsonWriter.Formatting = _formatting.Value; } DateFormatHandling?previousDateFormatHandling = null; if (_dateFormatHandling != null && jsonWriter.DateFormatHandling != _dateFormatHandling) { previousDateFormatHandling = jsonWriter.DateFormatHandling; jsonWriter.DateFormatHandling = _dateFormatHandling.Value; } DateTimeZoneHandling?previousDateTimeZoneHandling = null; if (_dateTimeZoneHandling != null && jsonWriter.DateTimeZoneHandling != _dateTimeZoneHandling) { previousDateTimeZoneHandling = jsonWriter.DateTimeZoneHandling; jsonWriter.DateTimeZoneHandling = _dateTimeZoneHandling.Value; } FloatFormatHandling?previousFloatFormatHandling = null; if (_floatFormatHandling != null && jsonWriter.FloatFormatHandling != _floatFormatHandling) { previousFloatFormatHandling = jsonWriter.FloatFormatHandling; jsonWriter.FloatFormatHandling = _floatFormatHandling.Value; } StringEscapeHandling?previousStringEscapeHandling = null; if (_stringEscapeHandling != null && jsonWriter.StringEscapeHandling != _stringEscapeHandling) { previousStringEscapeHandling = jsonWriter.StringEscapeHandling; jsonWriter.StringEscapeHandling = _stringEscapeHandling.Value; } CultureInfo previousCulture = null; if (_culture != null && !_culture.Equals(jsonWriter.Culture)) { previousCulture = jsonWriter.Culture; jsonWriter.Culture = _culture; } string previousDateFormatString = null; if (_dateFormatStringSet && jsonWriter.DateFormatString != _dateFormatString) { previousDateFormatString = jsonWriter.DateFormatString; jsonWriter.DateFormatString = _dateFormatString; } TraceJsonWriter traceJsonWriter = (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? new TraceJsonWriter(jsonWriter) : null; JsonSerializerInternalWriter serializerWriter = new JsonSerializerInternalWriter(this); serializerWriter.Serialize(traceJsonWriter ?? jsonWriter, value, objectType); if (traceJsonWriter != null) { TraceWriter.Trace(TraceLevel.Verbose, "Serialized JSON: " + Environment.NewLine + traceJsonWriter.GetJson(), null); } // reset writer back to previous options if (previousFormatting != null) { jsonWriter.Formatting = previousFormatting.Value; } if (previousDateFormatHandling != null) { jsonWriter.DateFormatHandling = previousDateFormatHandling.Value; } if (previousDateTimeZoneHandling != null) { jsonWriter.DateTimeZoneHandling = previousDateTimeZoneHandling.Value; } if (previousFloatFormatHandling != null) { jsonWriter.FloatFormatHandling = previousFloatFormatHandling.Value; } if (previousStringEscapeHandling != null) { jsonWriter.StringEscapeHandling = previousStringEscapeHandling.Value; } if (_dateFormatStringSet) { jsonWriter.DateFormatString = previousDateFormatString; } if (previousCulture != null) { jsonWriter.Culture = previousCulture; } }
internal virtual void SerializeInternal(JsonWriter jsonWriter, object value) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); // set serialization options onto writer Formatting?previousFormatting = null; if (_formatting != null && jsonWriter.Formatting != _formatting) { previousFormatting = jsonWriter.Formatting; jsonWriter.Formatting = _formatting.Value; } DateFormatHandling?previousDateFormatHandling = null; if (_dateFormatHandling != null && jsonWriter.DateFormatHandling != _dateFormatHandling) { previousDateFormatHandling = jsonWriter.DateFormatHandling; jsonWriter.DateFormatHandling = _dateFormatHandling.Value; } DateTimeZoneHandling?previousDateTimeZoneHandling = null; if (_dateTimeZoneHandling != null && jsonWriter.DateTimeZoneHandling != _dateTimeZoneHandling) { previousDateTimeZoneHandling = jsonWriter.DateTimeZoneHandling; jsonWriter.DateTimeZoneHandling = _dateTimeZoneHandling.Value; } FloatFormatHandling?previousFloatFormatHandling = null; if (_floatFormatHandling != null && jsonWriter.FloatFormatHandling != _floatFormatHandling) { previousFloatFormatHandling = jsonWriter.FloatFormatHandling; jsonWriter.FloatFormatHandling = _floatFormatHandling.Value; } StringEscapeHandling?previousStringEscapeHandling = null; if (_stringEscapeHandling != null && jsonWriter.StringEscapeHandling != _stringEscapeHandling) { previousStringEscapeHandling = jsonWriter.StringEscapeHandling; jsonWriter.StringEscapeHandling = _stringEscapeHandling.Value; } CultureInfo previousCulture = null; if (_culture != null && !_culture.Equals(jsonWriter.Culture)) { previousCulture = jsonWriter.Culture; jsonWriter.Culture = _culture; } string previousDateFormatString = null; if (_dateFormatStringSet && jsonWriter.DateFormatString != _dateFormatString) { previousDateFormatString = jsonWriter.DateFormatString; jsonWriter.DateFormatString = _dateFormatString; } JsonSerializerInternalWriter serializerWriter = new JsonSerializerInternalWriter(this); serializerWriter.Serialize(jsonWriter, value); // reset writer back to previous options if (previousFormatting != null) { jsonWriter.Formatting = previousFormatting.Value; } if (previousDateFormatHandling != null) { jsonWriter.DateFormatHandling = previousDateFormatHandling.Value; } if (previousDateTimeZoneHandling != null) { jsonWriter.DateTimeZoneHandling = previousDateTimeZoneHandling.Value; } if (previousFloatFormatHandling != null) { jsonWriter.FloatFormatHandling = previousFloatFormatHandling.Value; } if (previousStringEscapeHandling != null) { jsonWriter.StringEscapeHandling = previousStringEscapeHandling.Value; } if (_dateFormatStringSet) { jsonWriter.DateFormatString = previousDateFormatString; } if (previousCulture != null) { jsonWriter.Culture = previousCulture; } }
internal virtual void SerializeInternal(JsonWriter jsonWriter, object value, Type objectType) { TraceJsonWriter traceJsonWriter; ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); Newtonsoft.Json.Formatting?nullable = null; if (this._formatting.HasValue) { Newtonsoft.Json.Formatting formatting = jsonWriter.Formatting; Newtonsoft.Json.Formatting?nullable1 = this._formatting; if ((formatting == nullable1.GetValueOrDefault() ? !nullable1.HasValue : true)) { nullable = new Newtonsoft.Json.Formatting?(jsonWriter.Formatting); jsonWriter.Formatting = this._formatting.GetValueOrDefault(); } } Newtonsoft.Json.DateFormatHandling?nullable2 = null; if (this._dateFormatHandling.HasValue) { Newtonsoft.Json.DateFormatHandling dateFormatHandling = jsonWriter.DateFormatHandling; Newtonsoft.Json.DateFormatHandling?nullable3 = this._dateFormatHandling; if ((dateFormatHandling == nullable3.GetValueOrDefault() ? !nullable3.HasValue : true)) { nullable2 = new Newtonsoft.Json.DateFormatHandling?(jsonWriter.DateFormatHandling); jsonWriter.DateFormatHandling = this._dateFormatHandling.GetValueOrDefault(); } } Newtonsoft.Json.DateTimeZoneHandling?nullable4 = null; if (this._dateTimeZoneHandling.HasValue) { Newtonsoft.Json.DateTimeZoneHandling dateTimeZoneHandling = jsonWriter.DateTimeZoneHandling; Newtonsoft.Json.DateTimeZoneHandling?nullable5 = this._dateTimeZoneHandling; if ((dateTimeZoneHandling == nullable5.GetValueOrDefault() ? !nullable5.HasValue : true)) { nullable4 = new Newtonsoft.Json.DateTimeZoneHandling?(jsonWriter.DateTimeZoneHandling); jsonWriter.DateTimeZoneHandling = this._dateTimeZoneHandling.GetValueOrDefault(); } } Newtonsoft.Json.FloatFormatHandling?nullable6 = null; if (this._floatFormatHandling.HasValue) { Newtonsoft.Json.FloatFormatHandling floatFormatHandling = jsonWriter.FloatFormatHandling; Newtonsoft.Json.FloatFormatHandling?nullable7 = this._floatFormatHandling; if ((floatFormatHandling == nullable7.GetValueOrDefault() ? !nullable7.HasValue : true)) { nullable6 = new Newtonsoft.Json.FloatFormatHandling?(jsonWriter.FloatFormatHandling); jsonWriter.FloatFormatHandling = this._floatFormatHandling.GetValueOrDefault(); } } Newtonsoft.Json.StringEscapeHandling?nullable8 = null; if (this._stringEscapeHandling.HasValue) { Newtonsoft.Json.StringEscapeHandling stringEscapeHandling = jsonWriter.StringEscapeHandling; Newtonsoft.Json.StringEscapeHandling?nullable9 = this._stringEscapeHandling; if ((stringEscapeHandling == nullable9.GetValueOrDefault() ? !nullable9.HasValue : true)) { nullable8 = new Newtonsoft.Json.StringEscapeHandling?(jsonWriter.StringEscapeHandling); jsonWriter.StringEscapeHandling = this._stringEscapeHandling.GetValueOrDefault(); } } CultureInfo culture = null; if (this._culture != null && !this._culture.Equals(jsonWriter.Culture)) { culture = jsonWriter.Culture; jsonWriter.Culture = this._culture; } string dateFormatString = null; if (this._dateFormatStringSet && jsonWriter.DateFormatString != this._dateFormatString) { dateFormatString = jsonWriter.DateFormatString; jsonWriter.DateFormatString = this._dateFormatString; } if (this.TraceWriter == null || this.TraceWriter.LevelFilter < TraceLevel.Verbose) { traceJsonWriter = null; } else { traceJsonWriter = new TraceJsonWriter(jsonWriter); } TraceJsonWriter traceJsonWriter1 = traceJsonWriter; JsonSerializerInternalWriter jsonSerializerInternalWriter = new JsonSerializerInternalWriter(this); JsonWriter jsonWriter1 = traceJsonWriter1; if (jsonWriter1 == null) { jsonWriter1 = jsonWriter; } jsonSerializerInternalWriter.Serialize(jsonWriter1, value, objectType); if (traceJsonWriter1 != null) { this.TraceWriter.Trace(TraceLevel.Verbose, traceJsonWriter1.GetSerializedJsonMessage(), null); } if (nullable.HasValue) { jsonWriter.Formatting = nullable.GetValueOrDefault(); } if (nullable2.HasValue) { jsonWriter.DateFormatHandling = nullable2.GetValueOrDefault(); } if (nullable4.HasValue) { jsonWriter.DateTimeZoneHandling = nullable4.GetValueOrDefault(); } if (nullable6.HasValue) { jsonWriter.FloatFormatHandling = nullable6.GetValueOrDefault(); } if (nullable8.HasValue) { jsonWriter.StringEscapeHandling = nullable8.GetValueOrDefault(); } if (this._dateFormatStringSet) { jsonWriter.DateFormatString = dateFormatString; } if (culture != null) { jsonWriter.Culture = culture; } }
public JsonSerializerProxy(JsonSerializerInternalWriter serializerWriter) { ValidationUtils.ArgumentNotNull((object)serializerWriter, nameof(serializerWriter)); this._serializerWriter = serializerWriter; this._serializer = serializerWriter.Serializer; }
internal virtual void SerializeInternal(JsonWriter jsonWriter, object value, Type objectType) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); Formatting?formatting = null; if (this._formatting.HasValue && jsonWriter.Formatting != this._formatting) { formatting = new Formatting?(jsonWriter.Formatting); jsonWriter.Formatting = this._formatting.Value; } DateFormatHandling?dateFormatHandling = null; if (this._dateFormatHandling.HasValue && jsonWriter.DateFormatHandling != this._dateFormatHandling) { dateFormatHandling = new DateFormatHandling?(jsonWriter.DateFormatHandling); jsonWriter.DateFormatHandling = this._dateFormatHandling.Value; } DateTimeZoneHandling?dateTimeZoneHandling = null; if (this._dateTimeZoneHandling.HasValue && jsonWriter.DateTimeZoneHandling != this._dateTimeZoneHandling) { dateTimeZoneHandling = new DateTimeZoneHandling?(jsonWriter.DateTimeZoneHandling); jsonWriter.DateTimeZoneHandling = this._dateTimeZoneHandling.Value; } FloatFormatHandling?floatFormatHandling = null; if (this._floatFormatHandling.HasValue && jsonWriter.FloatFormatHandling != this._floatFormatHandling) { floatFormatHandling = new FloatFormatHandling?(jsonWriter.FloatFormatHandling); jsonWriter.FloatFormatHandling = this._floatFormatHandling.Value; } StringEscapeHandling?stringEscapeHandling = null; if (this._stringEscapeHandling.HasValue && jsonWriter.StringEscapeHandling != this._stringEscapeHandling) { stringEscapeHandling = new StringEscapeHandling?(jsonWriter.StringEscapeHandling); jsonWriter.StringEscapeHandling = this._stringEscapeHandling.Value; } CultureInfo cultureInfo = null; if (this._culture != null && !this._culture.Equals(jsonWriter.Culture)) { cultureInfo = jsonWriter.Culture; jsonWriter.Culture = this._culture; } string dateFormatString = null; if (this._dateFormatStringSet && jsonWriter.DateFormatString != this._dateFormatString) { dateFormatString = jsonWriter.DateFormatString; jsonWriter.DateFormatString = this._dateFormatString; } TraceJsonWriter traceJsonWriter = (this.TraceWriter != null && this.TraceWriter.LevelFilter >= TraceLevel.Verbose) ? new TraceJsonWriter(jsonWriter) : null; JsonSerializerInternalWriter jsonSerializerInternalWriter = new JsonSerializerInternalWriter(this); jsonSerializerInternalWriter.Serialize(traceJsonWriter ?? jsonWriter, value, objectType); if (traceJsonWriter != null) { this.TraceWriter.Trace(TraceLevel.Verbose, "Serialized JSON: " + Environment.NewLine + traceJsonWriter.GetJson(), null); } if (formatting.HasValue) { jsonWriter.Formatting = formatting.Value; } if (dateFormatHandling.HasValue) { jsonWriter.DateFormatHandling = dateFormatHandling.Value; } if (dateTimeZoneHandling.HasValue) { jsonWriter.DateTimeZoneHandling = dateTimeZoneHandling.Value; } if (floatFormatHandling.HasValue) { jsonWriter.FloatFormatHandling = floatFormatHandling.Value; } if (stringEscapeHandling.HasValue) { jsonWriter.StringEscapeHandling = stringEscapeHandling.Value; } if (this._dateFormatStringSet) { jsonWriter.DateFormatString = dateFormatString; } if (cultureInfo != null) { jsonWriter.Culture = cultureInfo; } }