XmlException.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // XmlException.cs
  3. //
  4. // Author:
  5. // Jason Diamond ([email protected])
  6. //
  7. // (C) 2002 Jason Diamond http://injektilo.org/
  8. //
  9. using System;
  10. using System.Runtime.Serialization;
  11. namespace System.Xml
  12. {
  13. [Serializable]
  14. public class XmlException : SystemException
  15. {
  16. #region Fields
  17. string msg; // Cache message here because SystemException doesn't expose it
  18. int lineNumber;
  19. int linePosition;
  20. #endregion
  21. #region Constructors
  22. public XmlException (string message, Exception innerException)
  23. : base (message, innerException)
  24. {
  25. msg = message;
  26. }
  27. protected XmlException (SerializationInfo info, StreamingContext context)
  28. : base (info, context)
  29. {
  30. this.lineNumber = info.GetInt32 ("lineNumber");
  31. this.linePosition = info.GetInt32 ("linePosition");
  32. }
  33. internal XmlException (string message)
  34. : base (message)
  35. {
  36. msg = message;
  37. }
  38. internal XmlException (string message, int lineNumber, int linePosition) : base (message)
  39. {
  40. this.lineNumber = lineNumber;
  41. this.linePosition = linePosition;
  42. }
  43. #endregion
  44. #region Properties
  45. public int LineNumber {
  46. get { return lineNumber; }
  47. }
  48. public int LinePosition {
  49. get { return linePosition; }
  50. }
  51. public override string Message {
  52. get { return msg; }
  53. }
  54. #endregion
  55. #region Methods
  56. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  57. {
  58. base.GetObjectData (info, context);
  59. info.AddValue ("lineNumber", lineNumber);
  60. info.AddValue ("linePosition", linePosition);
  61. }
  62. #endregion
  63. }
  64. }