public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            UserBreadcrumb userBreadcrumb = (UserBreadcrumb)value;
            JToken         t = userBreadcrumb.ToJToken();

            t.WriteTo(writer);
        }
        internal static List <UserBreadcrumb> ConvertToUserBreadcrumbs(List <Breadcrumb> session, bool windowsStyle)
        {
            // Convert List<Breadcrumb> to List<UserBreadcrumb> .
            List <UserBreadcrumb> answer = new List <UserBreadcrumb>();

            foreach (Breadcrumb breadcrumb in session)
            {
                UserBreadcrumb userBreadcrumb = new UserBreadcrumb(breadcrumb, windowsStyle);
                answer.Add(userBreadcrumb);
            }
            return(answer);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            UserBreadcrumb userBreadcrumb = null;
            // Load JObject from stream .  For better or worse, probably a bit of the latter,
            // Newtonsoft.Json deserializes a persisted timestamp string as a JTokenType.Date .
            JToken t            = JToken.Load(reader);
            string timestamp    = "";
            string message      = "";
            bool   windowsStyle = true;

            if (IsUserBreadcrumbJson(t))
            {
                if (t.Type == JTokenType.Object)
                {
                    // Extract values from "JObject o" .
                    JObject o = (JObject)t;
                    timestamp    = JsonUtils.JsonDateToGMTDateString(o["timestamp"]);
                    message      = (string)((JValue)(o["message"])).Value;
                    windowsStyle = true;
                }
                else if (t.Type == JTokenType.Array)
                {
                    // Extract values from "JArray a" .
                    JArray a = (JArray)t;
                    timestamp    = JsonUtils.JsonDateToGMTDateString(a[0]);
                    message      = (string)((JValue)(a[1])).Value;
                    windowsStyle = false;
                }
                else
                {
                    // Shouldn't get here.
                    Debug.Assert(false, "ReadJson failure");
                }
                // Call UserBreadcrumb constructor.
                userBreadcrumb = new UserBreadcrumb(
                    timestamp,
                    message,
                    windowsStyle
                    );
            }
            return(userBreadcrumb);
        }