public static ReportException FromException(Exception ex) { if (ex == null) { throw new ArgumentNullException("ex"); } ReportException rex = new ReportException(); if (ex.GetType() == typeof(TargetInvocationException) && ex.InnerException != null) { ex = ex.InnerException; } rex.Type = ex.GetType().ToString(); rex.Message = String.Format("{0}", ex.Message); rex.Source = String.Format("{0}", ex.Source); rex.StackTrace = ex.StackTrace; if (ex.InnerException != null) { rex.Exception = FromException(ex.InnerException); } foreach (PropertyInfo property in ex.GetType().GetProperties()) { if (property.Name == "Message" || property.Name == "Source" || property.Name == "StackTrace" || property.Name == "InnerException" || property.Name == "Data") { continue; } ReportProperty p = new ReportProperty(ex, property); rex.Properties.AddReportProperty(p); } /* * if (ex.Data!=null) * { * foreach (DictionaryEntry de in ex.Data) * { * ReportProperty p = new ReportProperty(de); * rex.Properties.Add(p); * } * } */ return(rex); }
/// <summary /> /// <remarks /> public void RemoveReportProperty(ReportProperty o) { this.List.Remove(o); }
/// <summary /> /// <remarks /> public bool ContainsReportProperty(ReportProperty o) { return(this.List.Contains(o)); }
/// <summary /> /// <remarks /> public void AddReportProperty(ReportProperty o) { this.List.Add(o); }
/// <summary /> /// <remarks /> public bool ContainsReportProperty(ReportProperty o) { return this.List.Contains(o); }
public static ReportException FromException(Exception ex) { if (ex==null) throw new ArgumentNullException("ex"); ReportException rex = new ReportException(); if (ex.GetType() == typeof(TargetInvocationException) && ex.InnerException!=null) ex = ex.InnerException; rex.Type = ex.GetType().ToString(); rex.Message = String.Format("{0}",ex.Message); rex.Source = String.Format("{0}",ex.Source); rex.StackTrace = ex.StackTrace; if (ex.InnerException!=null) rex.Exception = FromException(ex.InnerException); foreach (PropertyInfo property in ex.GetType().GetProperties()) { if (property.Name == "Message" || property.Name == "Source" || property.Name == "StackTrace" || property.Name == "InnerException" || property.Name == "Data") continue; ReportProperty p = new ReportProperty(ex, property); rex.Properties.AddReportProperty(p); } /* if (ex.Data!=null) { foreach (DictionaryEntry de in ex.Data) { ReportProperty p = new ReportProperty(de); rex.Properties.Add(p); } } */ return rex; }