XmlException.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. {
  29. this.lineNumber = info.GetInt32 ("lineNumber");
  30. this.linePosition = info.GetInt32 ("linePosition");
  31. }
  32. internal XmlException (string message)
  33. : base (message)
  34. {
  35. msg = message;
  36. }
  37. internal XmlException (string message, int lineNumber, int linePosition) : base (message)
  38. {
  39. this.lineNumber = lineNumber;
  40. this.linePosition = linePosition;
  41. }
  42. #endregion
  43. #region Properties
  44. public int LineNumber {
  45. get { return lineNumber; }
  46. }
  47. public int LinePosition {
  48. get { return linePosition; }
  49. }
  50. public override string Message {
  51. get { return msg; }
  52. }
  53. #endregion
  54. #region Methods
  55. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  56. {
  57. base.GetObjectData (info, context);
  58. info.AddValue ("lineNumber", lineNumber);
  59. info.AddValue ("linePosition", linePosition);
  60. }
  61. #endregion
  62. }
  63. }