public static IEnumerable <KeyValuePair <string, object> > ParseItem(object item) { if (item == null) { return((IEnumerable <KeyValuePair <string, object> >)null); } IDictionary <string, object> dictionary = item as IDictionary <string, object>; if (dictionary != null) { return((IEnumerable <KeyValuePair <string, object> >)dictionary); } Type type = item.GetType(); if (RawBlobParser.IsAnonymousType(type)) { return(((IEnumerable <PropertyInfo>)item.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty)).Where <PropertyInfo>((Func <PropertyInfo, bool>)(propertyInfo => !((IEnumerable <ParameterInfo>)propertyInfo.GetIndexParameters()).Any <ParameterInfo>())).Select(propertyInfo => { PropertyInfo propertyInfo1 = propertyInfo; object obj1 = item; // ISSUE: variable of the null type object local = null; object obj2 = propertyInfo1.GetValue(obj1, (object[])local); return new { propertyInfo = propertyInfo1, unwrappedItem = obj2 }; }).Where(param0 => param0.unwrappedItem != null).Select(param0 => new KeyValuePair <string, object>(param0.propertyInfo.Name, param0.unwrappedItem))); } return((IEnumerable <KeyValuePair <string, object> >) new KeyValuePair <string, object>[1] { new KeyValuePair <string, object>(type.Name, item) }); }
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 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)); } }