public static string ToJson(this System.Diagnostics.Tracing.EventWrittenEventArgs eventArgs)
        {
            var names = eventArgs.PayloadNames;
            var count = names.Count;

            using (var sw = new StringWriter())
                using (var jw = new Json.TinyJsonWriter(sw))
                {
                    jw.WriteStartObject();
                    for (int i = 0; i < count; i++)
                    {
                        var name  = names[i];
                        var value = eventArgs.Payload[i];

                        jw.WritePropertyName(name);
                        jw.WriteValue(value);
                    }
                    jw.WriteEndObject();
                    sw.Flush();
                    return(sw.ToString());
                }
        }
        public static string ToJson(this TraceEvent traceEvent)
        {
            var names = traceEvent.PayloadNames;
            var count = names.Length;

            using (var sw = new StringWriter())
            using (var jw = new Json.TinyJsonWriter(sw))
            {
                jw.WriteStartObject();
                for (int i = 0; i < count; i++)
                {
                    var name = names[i];
                    var value = traceEvent.PayloadString(i);

                    jw.WritePropertyName(name);
                    jw.WriteValue(value);
                }
                jw.WriteEndObject();
                sw.Flush();
                return sw.ToString();
            }
        }
Exemple #3
0
        public static string ToJson(this TraceEvent traceEvent)
        {
            var names = traceEvent.PayloadNames;
            var count = names.Length;

            using (var sw = new StringWriter())
                using (var jw = new Json.TinyJsonWriter(sw))
                {
                    jw.WriteStartObject();
                    for (int i = 0; i < count; i++)
                    {
                        var name  = names[i];
                        var value = traceEvent.PayloadString(i);

                        jw.WritePropertyName(name);
                        jw.WriteValue(value);
                    }
                    jw.WriteEndObject();
                    sw.Flush();
                    return(sw.ToString());
                }
        }
        public static string ToJson(this System.Diagnostics.Tracing.EventWrittenEventArgs eventArgs)
        {
            var names = eventArgs.PayloadNames;
            var count = names.Count;

            using (var sw = new StringWriter())
            using (var jw = new Json.TinyJsonWriter(sw))
            {
                jw.WriteStartObject();
                for (int i = 0; i < count; i++)
                {
                    var name = names[i];
                    var value = eventArgs.Payload[i];

                    jw.WritePropertyName(name);
                    jw.WriteValue(value);
                }
                jw.WriteEndObject();
                sw.Flush();
                return sw.ToString();
            }
        }