/// <summary>
 /// Writes a trace event message to the trace listeners in the Listeners collection using the specified event type and event identifier.
 /// </summary>
 /// <param name="traceSource">The 'TraceSource' instance.</param>
 /// <param name="traceEventType">One of the enumeration values that specifies the event type of the trace data.</param>
 /// <param name="message">The informative message to write.</param>
 /// <param name="duration">The trace event duration.</param>
 /// <param name="status">One of the enumeration values that specifies the event status of the trace event.</param>
 /// <param name="exception">THe exception that to trace as part of the trace event.</param>
 /// <param name="data">The trace data.</param>
 /// <param name="methodName">The calling method where the log originated from</param>
 internal static void TraceEventInternal(this TraceSource traceSource, TraceEventType traceEventType, string message, TimeSpan duration, TraceStatus status, Exception exception, IEnumerable <KeyValuePair <string, object> > data, string methodName)
 {
     try
     {
         if (!TraceSourceExt.ShouldTrace(traceSource, traceEventType))
         {
             return;
         }
         TraceEventEntry traceEventEntry = TraceEventEntryBuilder.IncludeEnvironmentData(new TraceEventEntry()
         {
             ApplicationName = traceSource.Name,
             EventData       = TraceSourceExt.EventDataBuilder.CreateTraceEventData(exception, data),
             EventDuration   = duration,
             EventKeys       = TraceSourceExt.EventDataBuilder.CreateEventKeys(TraceSourceExt.GetKeys()),
             EventType       = traceEventType.ToString(),
             Message         = message,
             MethodName      = methodName,
             Status          = (int)status
         });
         traceSource.TraceData(traceEventType, 0, (object)traceEventEntry);
         traceSource.Flush();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(string.Format("An error occurred while tracing. {0}", (object)ex.Message));
     }
 }
 /// <summary>
 /// Writes a trace event message to the trace listeners in the Listeners collection using the specified event type and event identifier.
 /// </summary>
 /// <param name="traceSource">The 'TraceSource' instance.</param>
 /// <param name="traceEventType">One of the enumeration values that specifies the event type of the trace data.</param>
 /// <param name="message">The informative message to write.</param>
 /// <param name="duration">The trace event duration.</param>
 /// <param name="status">One of the enumeration values that specifies the event status of the trace event.</param>
 /// <param name="exception">THe exception that to trace as part of the trace event.</param>
 /// <param name="data">The trace data.</param>
 /// <param name="methodName">The calling method where the log originated from</param>
 private static void TraceEventWithDataArrayInternal(this TraceSource traceSource, TraceEventType traceEventType, string message, TimeSpan duration, TraceStatus status, Exception exception, object[] data, string methodName)
 {
     try
     {
         if (!TraceSourceExt.ShouldTrace(traceSource, traceEventType))
         {
             return;
         }
         ICollection <KeyValuePair <string, object> > items = RawBlobParser.ParseItems((IList <object>)data);
         TraceSourceExt.TraceEventInternal(traceSource, traceEventType, message, duration, status, exception, (IEnumerable <KeyValuePair <string, object> >)items, methodName);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(string.Format("An error occurred while tracing. {0}", (object)ex.Message));
     }
 }