public static ICollection <KeyValuePair <string, object> > ParseItems(IList <object> blobs) { if (blobs == null) { return((ICollection <KeyValuePair <string, object> >)null); } List <KeyValuePair <string, object> > keyValuePairList = (List <KeyValuePair <string, object> >)null; foreach (object blob in (IEnumerable <object>)blobs) { if (blob != null) { IEnumerable <KeyValuePair <string, object> > keyValuePairs = RawBlobParser.ParseItem(blob); if (keyValuePairs != null) { foreach (KeyValuePair <string, object> keyValuePair in keyValuePairs) { if (keyValuePairList == null) { keyValuePairList = new List <KeyValuePair <string, object> >(); } keyValuePairList.Add(keyValuePair); } } } } return((ICollection <KeyValuePair <string, object> >)keyValuePairList); }
/// <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 TraceEventInternal(this TraceSource traceSource, TraceEventType traceEventType, string message, TimeSpan duration, TraceStatus status, Exception exception, object data, string methodName) { try { if (!TraceSourceExt.ShouldTrace(traceSource, traceEventType)) { return; } IEnumerable <KeyValuePair <string, object> > data1 = RawBlobParser.ParseItem(data); TraceSourceExt.TraceEventInternal(traceSource, traceEventType, message, duration, status, exception, data1, methodName); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("An error occurred while tracing. {0}", (object)ex.Message)); } }