Added more stuff to various Exceptions to make them serializable
[mono.git] / mcs / class / corlib / System / ObjectDisposedException.cs
1 //
2 // System.ObjectDisposedException.cs
3 //
4 // Author:
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.Globalization;
12 using System.Runtime.Serialization;
13
14 namespace System {
15
16         [Serializable]
17         public class ObjectDisposedException : InvalidOperationException {
18                 private string obj_name;
19                 private string msg;
20
21                 // Constructors
22                 public ObjectDisposedException (string objectName)
23                         : base (Locale.GetText ("The object was used after being disposed"))
24                 {
25                         obj_name = objectName;
26                         msg = Locale.GetText ("The object was used after being disposed");
27                 }
28
29                 public ObjectDisposedException (string objectName, string message) 
30                         : base (message)
31                 {
32                         obj_name = objectName;
33                         msg = message;
34                 }
35
36                 protected ObjectDisposedException (SerializationInfo info, StreamingContext context)
37                         : base (info, context)
38                 {
39                         obj_name = info.GetString ("ObjectName");
40                 }
41
42                 // Properties
43                 public override string Message
44                 {
45                         get { return msg; }
46                 }
47
48                 public string ObjectName
49                 {
50                         get { return obj_name; }
51                 }
52
53                 
54                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
55                 {
56                         base.GetObjectData (info, context);
57                         info.AddValue ("ObjectName", obj_name);
58                 }
59         }
60 }