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                 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                         get { return msg; }
45                 }
46
47                 public string ObjectName {
48                         get { return obj_name; }
49                 }
50
51                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
52                 {
53                         base.GetObjectData (info, context);
54                         info.AddValue ("ObjectName", obj_name);
55                 }
56         }
57 }