FileLoadException.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //
  2. // System.IO.FileLoadException.cs
  3. //
  4. // Author:
  5. // Paolo Molaro ([email protected])
  6. // Duncan Mak ([email protected])
  7. //
  8. // (C) 2001 Ximian, Inc. http://www.ximian.com
  9. //
  10. //
  11. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. using System.Globalization;
  33. using System.IO;
  34. using System.Runtime.Serialization;
  35. namespace System.IO {
  36. [Serializable]
  37. public class FileLoadException : IOException {
  38. // Fields
  39. string msg;
  40. Exception inner;
  41. string fileName;
  42. string fusionLog;
  43. // Constructors
  44. public FileLoadException ()
  45. : base (Locale.GetText ("I/O Error"))
  46. {
  47. msg = Locale.GetText ("I/O Error");
  48. }
  49. public FileLoadException (string message)
  50. : base (message)
  51. {
  52. msg = message;
  53. }
  54. public FileLoadException (string message, string fileName)
  55. : base (message)
  56. {
  57. this.msg = message;
  58. this.fileName = fileName;
  59. }
  60. public FileLoadException (string message, Exception inner)
  61. : base (message, inner)
  62. {
  63. msg = message;
  64. this.inner = inner;
  65. }
  66. public FileLoadException (string message, string fileName, Exception inner)
  67. : base (message, inner)
  68. {
  69. this.msg = message;
  70. this.fileName = fileName;
  71. this.inner = inner;
  72. }
  73. protected FileLoadException (SerializationInfo info, StreamingContext context)
  74. {
  75. fileName = info.GetString ("FileLoad_FileName");
  76. fusionLog = info.GetString ("FileLoad_FusionLog");
  77. }
  78. // Properties
  79. public override string Message
  80. {
  81. get {
  82. if (fileName != null)
  83. return Locale.GetText (msg + ": " + fileName);
  84. else
  85. return msg;
  86. }
  87. }
  88. public string FileName
  89. {
  90. get { return fileName; }
  91. }
  92. public string FusionLog
  93. {
  94. get { return fusionLog; }
  95. }
  96. // Methods
  97. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  98. {
  99. base.GetObjectData (info, context);
  100. info.AddValue ("FileLoad_FileName", fileName);
  101. info.AddValue ("FileLoad_FusionLog", fusionLog);
  102. }
  103. public override string ToString ()
  104. {
  105. string result = GetType ().FullName + ": " + Message;
  106. if (this.InnerException != null)
  107. result +=" ----> " + InnerException;
  108. if (this.StackTrace != null)
  109. result += '\n' + StackTrace;
  110. return result;
  111. }
  112. }
  113. }