Ext.Net.ISODateTimeJsonConverter.ReadJson C# (CSharp) Method

ReadJson() public method

Reads the JSON representation of the object.
public ReadJson ( Newtonsoft reader, Type objectType, object existingValue, JsonSerializer serializer ) : object
reader Newtonsoft The to read from.
objectType System.Type Type of the object.
existingValue object Existing Value
serializer Newtonsoft.Json.JsonSerializer Serializer
return object
        public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType != JsonToken.String)
                throw new Exception("Unexpected token parsing date. Expected String, got {0}.".FormatWith(reader.TokenType));

            string dateText = reader.Value.ToString();

            if (objectType == typeof(DateTimeOffset))
                return DateTimeOffset.Parse(dateText, CultureInfo.InvariantCulture, dateTimeStyles);

            return DateTime.Parse(dateText, CultureInfo.InvariantCulture, dateTimeStyles);
        }
ISODateTimeJsonConverter