internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); }
internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return(EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable)); }
private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { if (floatFormatHandling == FloatFormatHandling.Symbol || !(double.IsInfinity(value) || double.IsNaN(value))) return text; if (floatFormatHandling == FloatFormatHandling.DefaultValue) return (!nullable) ? "0.0" : Null; return quoteChar + text + quoteChar; }
internal virtual void SerializeInternal([Nullable(1)] JsonWriter jsonWriter, object value, Type objectType) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); Formatting?formatting = null; if (this._formatting != null) { Formatting formatting2 = jsonWriter.Formatting; Formatting?formatting3 = this._formatting; if (!(formatting2 == formatting3.GetValueOrDefault() & formatting3 != null)) { formatting = new Formatting?(jsonWriter.Formatting); jsonWriter.Formatting = this._formatting.GetValueOrDefault(); } } DateFormatHandling?dateFormatHandling = null; if (this._dateFormatHandling != null) { DateFormatHandling dateFormatHandling2 = jsonWriter.DateFormatHandling; DateFormatHandling?dateFormatHandling3 = this._dateFormatHandling; if (!(dateFormatHandling2 == dateFormatHandling3.GetValueOrDefault() & dateFormatHandling3 != null)) { dateFormatHandling = new DateFormatHandling?(jsonWriter.DateFormatHandling); jsonWriter.DateFormatHandling = this._dateFormatHandling.GetValueOrDefault(); } } DateTimeZoneHandling?dateTimeZoneHandling = null; if (this._dateTimeZoneHandling != null) { DateTimeZoneHandling dateTimeZoneHandling2 = jsonWriter.DateTimeZoneHandling; DateTimeZoneHandling?dateTimeZoneHandling3 = this._dateTimeZoneHandling; if (!(dateTimeZoneHandling2 == dateTimeZoneHandling3.GetValueOrDefault() & dateTimeZoneHandling3 != null)) { dateTimeZoneHandling = new DateTimeZoneHandling?(jsonWriter.DateTimeZoneHandling); jsonWriter.DateTimeZoneHandling = this._dateTimeZoneHandling.GetValueOrDefault(); } } FloatFormatHandling?floatFormatHandling = null; if (this._floatFormatHandling != null) { FloatFormatHandling floatFormatHandling2 = jsonWriter.FloatFormatHandling; FloatFormatHandling?floatFormatHandling3 = this._floatFormatHandling; if (!(floatFormatHandling2 == floatFormatHandling3.GetValueOrDefault() & floatFormatHandling3 != null)) { floatFormatHandling = new FloatFormatHandling?(jsonWriter.FloatFormatHandling); jsonWriter.FloatFormatHandling = this._floatFormatHandling.GetValueOrDefault(); } } StringEscapeHandling?stringEscapeHandling = null; if (this._stringEscapeHandling != null) { StringEscapeHandling stringEscapeHandling2 = jsonWriter.StringEscapeHandling; StringEscapeHandling?stringEscapeHandling3 = this._stringEscapeHandling; if (!(stringEscapeHandling2 == stringEscapeHandling3.GetValueOrDefault() & stringEscapeHandling3 != null)) { stringEscapeHandling = new StringEscapeHandling?(jsonWriter.StringEscapeHandling); jsonWriter.StringEscapeHandling = this._stringEscapeHandling.GetValueOrDefault(); } } 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) ? null : new TraceJsonWriter(jsonWriter); new JsonSerializerInternalWriter(this).Serialize(traceJsonWriter ?? jsonWriter, value, objectType); if (traceJsonWriter != null) { this.TraceWriter.Trace(TraceLevel.Verbose, traceJsonWriter.GetSerializedJsonMessage(), null); } if (formatting != null) { jsonWriter.Formatting = formatting.GetValueOrDefault(); } if (dateFormatHandling != null) { jsonWriter.DateFormatHandling = dateFormatHandling.GetValueOrDefault(); } if (dateTimeZoneHandling != null) { jsonWriter.DateTimeZoneHandling = dateTimeZoneHandling.GetValueOrDefault(); } if (floatFormatHandling != null) { jsonWriter.FloatFormatHandling = floatFormatHandling.GetValueOrDefault(); } if (stringEscapeHandling != null) { jsonWriter.StringEscapeHandling = stringEscapeHandling.GetValueOrDefault(); } if (this._dateFormatStringSet) { jsonWriter.DateFormatString = dateFormatString; } if (cultureInfo != null) { jsonWriter.Culture = cultureInfo; } }