2004-03-09 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
[mono.git] / mcs / class / corlib / System / ObjectDisposedException.cs
1 //
2 // System.ObjectDisposedException.cs
3 //
4 // Authors:
5 //   Paolo Molaro (lupus@ximian.com)
6 //   Duncan Mak (duncan@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System.Runtime.Serialization;
12
13 namespace System
14 {
15         [Serializable]
16         public class ObjectDisposedException : InvalidOperationException
17         {
18                 // Does not override the HResult from InvalidOperationException
19
20                 private string obj_name;
21                 private string msg;
22
23                 // Constructors
24                 public ObjectDisposedException (string objectName)
25                         : base (Locale.GetText ("The object was used after being disposed."))
26                 {
27                         obj_name = objectName;
28                         msg = Locale.GetText ("The object was used after being disposed.");
29                 }
30
31                 public ObjectDisposedException (string objectName, string message) 
32                         : base (message)
33                 {
34                         obj_name = objectName;
35                         msg = message;
36                 }
37
38                 protected ObjectDisposedException (SerializationInfo info, StreamingContext context)
39                         : base (info, context)
40                 {
41                         obj_name = info.GetString ("ObjectName");
42                 }
43
44                 // Properties
45                 public override string Message {
46                         get { return msg; }
47                 }
48
49                 public string ObjectName {
50                         get { return obj_name; }
51                 }
52
53                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
54                 {
55                         base.GetObjectData (info, context);
56                         info.AddValue ("ObjectName", obj_name);
57                 }
58         }
59 }