/// <summary> /// Parses the given XML-representation and creates an <see cref="ErrorReport"/> off of it. /// </summary> /// <param name="xml">The XML-representation to convert.</param> /// <returns></returns> public static ErrorReport Deserialize(string xml) { XDocument doc = XDocument.Parse(xml); XElement root = doc.Root; ErrorReport report = new ErrorReport(); report.Timestamp = DateTime.Parse(root.Element("Timestamp").Value).ToUniversalTime(); report.SourceComponentName = root.Element("ComponentName").Value; report.IsTerminating = bool.Parse(root.Element("IsTerminating").Value); report.Exception = ExceptionDetail.Deserialize(root.Element("ExceptionDetail")); return(report); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionDetail"/> class. /// </summary> /// <param name="exception">The exception object. Must not be null.</param> internal ExceptionDetail(Exception exception) : this() { Assertions.AssertNotNull(exception, "exception"); this.Type = exception.GetType().AssemblyQualifiedName; this.Message = exception.Message; this.Source = exception.Source; this.StackTrace = exception.StackTrace; if (exception.InnerException != null) { this.InnerException = new ExceptionDetail(exception.InnerException); } }
/// <summary> /// Parses the given XML-representation and creates an <see cref="ExceptionDetail"/> off of it. /// </summary> /// <param name="xml">The XML-representation to convert.</param> /// <returns></returns> internal static ExceptionDetail Deserialize(XElement xml) { ExceptionDetail detail = new ExceptionDetail(); detail.Type = xml.Attribute("Type").Value; detail.Message = xml.Element("Message").Value; detail.Source = xml.Element("Source").Value; detail.StackTrace = xml.Element("StackTrace").Value; XElement innerException = xml.Element("ExceptionDetail"); if (innerException != null) { detail.InnerException = Deserialize(innerException); } return(detail); }
/// <summary> /// Parses the given XML-representation and creates an <see cref="ExceptionDetail"/> off of it. /// </summary> /// <param name="xml">The XML-representation to convert.</param> /// <returns></returns> internal static ExceptionDetail Deserialize(XElement xml) { ExceptionDetail detail = new ExceptionDetail(); detail.Type = xml.Attribute("Type").Value; detail.Message = xml.Element("Message").Value; detail.Source = xml.Element("Source").Value; detail.StackTrace = xml.Element("StackTrace").Value; XElement innerException = xml.Element("ExceptionDetail"); if (innerException != null) { detail.InnerException = Deserialize(innerException); } return detail; }