XsltException.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // System.Xml.Xsl.XsltException.cs
  3. //
  4. // Authors:
  5. // Tim Coleman ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) Copyright 2002 Tim Coleman
  9. // (C) 2003 Andreas Nahr
  10. //
  11. using System;
  12. using System.Runtime.Serialization;
  13. using System.Xml.XPath;
  14. namespace System.Xml.Xsl
  15. {
  16. [Serializable]
  17. public class XsltException : SystemException
  18. {
  19. #region Fields
  20. string message;
  21. int lineNumber;
  22. int linePosition;
  23. string sourceUri;
  24. #endregion
  25. #region Constructors
  26. public XsltException (string message, Exception innerException)
  27. : base (message, innerException)
  28. {
  29. this.message = message;
  30. }
  31. protected XsltException (SerializationInfo info, StreamingContext context)
  32. {
  33. lineNumber = info.GetInt32 ("lineNumber");
  34. linePosition = info.GetInt32 ("linePosition");
  35. sourceUri = info.GetString ("sourceUri");
  36. }
  37. internal XsltException (string message, Exception innerException, int lineNumber, int linePosition, string sourceUri)
  38. : base (message, innerException)
  39. {
  40. this.lineNumber = lineNumber;
  41. this.linePosition = linePosition;
  42. this.sourceUri = sourceUri;
  43. }
  44. internal XsltException (string message, Exception innerException, XPathNavigator nav)
  45. : base (message, innerException)
  46. {
  47. IXmlLineInfo li = nav as IXmlLineInfo;
  48. this.lineNumber = li != null ? li.LineNumber : 0;
  49. this.linePosition = li != null ? li.LinePosition : 0;
  50. this.sourceUri = nav != null ? nav.BaseURI : String.Empty;
  51. }
  52. #endregion
  53. #region Properties
  54. public int LineNumber {
  55. get { return lineNumber; }
  56. }
  57. public int LinePosition {
  58. get { return linePosition; }
  59. }
  60. public override string Message {
  61. get { return message; }
  62. }
  63. public string SourceUri {
  64. get { return sourceUri; }
  65. }
  66. #endregion
  67. #region Methods
  68. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  69. {
  70. base.GetObjectData (info, context);
  71. info.AddValue ("lineNumber", lineNumber);
  72. info.AddValue ("linePosition", linePosition);
  73. info.AddValue ("sourceUri", sourceUri);
  74. }
  75. #endregion
  76. }
  77. }