Beispiel #1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            string str;

            if (value is DateTime)
            {
                DateTime time = (DateTime)value;
                if (((this.dateTimeStyles_0 & System.Globalization.DateTimeStyles.AdjustToUniversal) == System.Globalization.DateTimeStyles.AdjustToUniversal) || ((this.dateTimeStyles_0 & System.Globalization.DateTimeStyles.AssumeUniversal) == System.Globalization.DateTimeStyles.AssumeUniversal))
                {
                    time = time.ToUniversalTime();
                }
                str = time.ToString(this.string_1 ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK", this.Culture);
            }
            else
            {
                if (!(value is DateTimeOffset))
                {
                    throw new JsonSerializationException("Unexpected value when converting date. Expected DateTime or DateTimeOffset, got {0}.".smethod_0(CultureInfo.InvariantCulture, Class194.smethod_3(value)));
                }
                DateTimeOffset offset = (DateTimeOffset)value;
                if (((this.dateTimeStyles_0 & System.Globalization.DateTimeStyles.AdjustToUniversal) == System.Globalization.DateTimeStyles.AdjustToUniversal) || ((this.dateTimeStyles_0 & System.Globalization.DateTimeStyles.AssumeUniversal) == System.Globalization.DateTimeStyles.AssumeUniversal))
                {
                    offset = offset.ToUniversalTime();
                }
                str = offset.ToString(this.string_1 ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK", this.Culture);
            }
            writer.WriteValue(str);
        }