SerializableException.cs 1007 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.IO;
  3. using System.Xml.Serialization;
  4. namespace Xilium.CefGlue.Common.Shared.RendererProcessCommunication
  5. {
  6. [Serializable]
  7. public class SerializableException {
  8. public string ExceptionType { get; set; }
  9. public string Message { get; set; }
  10. public string StackTrace{ get; set; }
  11. public string SerializeToString()
  12. {
  13. var serializer = new XmlSerializer(typeof(SerializableException));
  14. using (var writer = new StringWriter())
  15. {
  16. serializer.Serialize(writer, this);
  17. return writer.ToString();
  18. }
  19. }
  20. public static SerializableException DeserializeFromString(string content)
  21. {
  22. var serializer = new XmlSerializer(typeof(SerializableException));
  23. using (var reader = new StringReader(content))
  24. {
  25. return (SerializableException) serializer.Deserialize(reader);
  26. }
  27. }
  28. }
  29. }