/// <summary>
        /// Get the timestamp from the log record.
        /// </summary>
        /// <param name="record">The record to extract timestamp.</param>
        /// <returns></returns>
        public DateTime GetTimestamp(DelimitedLogRecordBase record)
        {
            string[] values    = _fields.Select(f => record[f]).ToArray();
            string   formatted = string.Format(_formatSpec, values);

            return(DateTime.ParseExact(formatted, _parseSpec, CultureInfo.InvariantCulture));
        }
Example #2
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            JToken t = JToken.FromObject(value);

            if (t.Type != JTokenType.Object)
            {
                t.WriteTo(writer);
            }
            else
            {
                JObject o = (JObject)t;
                DelimitedLogRecordBase record = value as DelimitedLogRecordBase;
                o.AddFirst(new JProperty("Timestamp", record.TimeStamp));
                o.WriteTo(writer);
            }
        }