XsltException.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System;
  32. using System.Runtime.Serialization;
  33. using System.Xml.XPath;
  34. namespace System.Xml.Xsl
  35. {
  36. [Serializable]
  37. public class XsltException : SystemException
  38. {
  39. #region Fields
  40. int lineNumber;
  41. int linePosition;
  42. string sourceUri;
  43. #endregion
  44. #region Constructors
  45. public XsltException (string message, Exception innerException)
  46. : base (message, innerException)
  47. {
  48. // this.message = message;
  49. }
  50. protected XsltException (SerializationInfo info, StreamingContext context)
  51. {
  52. lineNumber = info.GetInt32 ("lineNumber");
  53. linePosition = info.GetInt32 ("linePosition");
  54. sourceUri = info.GetString ("sourceUri");
  55. }
  56. internal XsltException (string message, Exception innerException, int lineNumber, int linePosition, string sourceUri)
  57. : base (message, innerException)
  58. {
  59. this.lineNumber = lineNumber;
  60. this.linePosition = linePosition;
  61. this.sourceUri = sourceUri;
  62. }
  63. internal XsltException (string message, Exception innerException, XPathNavigator nav)
  64. : base (message, innerException)
  65. {
  66. IXmlLineInfo li = nav as IXmlLineInfo;
  67. this.lineNumber = li != null ? li.LineNumber : 0;
  68. this.linePosition = li != null ? li.LinePosition : 0;
  69. this.sourceUri = nav != null ? nav.BaseURI : String.Empty;
  70. }
  71. #endregion
  72. #region Properties
  73. public int LineNumber {
  74. get { return lineNumber; }
  75. }
  76. public int LinePosition {
  77. get { return linePosition; }
  78. }
  79. public override string Message {
  80. get {
  81. string msg = base.Message;
  82. if (sourceUri != null)
  83. msg += " " + sourceUri;
  84. if (lineNumber != 0)
  85. msg += " line " + lineNumber;
  86. if (linePosition != 0)
  87. msg += ", position " + linePosition;
  88. return msg;
  89. }
  90. }
  91. public string SourceUri {
  92. get { return sourceUri; }
  93. }
  94. #endregion
  95. #region Methods
  96. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  97. {
  98. base.GetObjectData (info, context);
  99. info.AddValue ("lineNumber", lineNumber);
  100. info.AddValue ("linePosition", linePosition);
  101. info.AddValue ("sourceUri", sourceUri);
  102. }
  103. #endregion
  104. }
  105. }