2002-07-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System / System.ComponentModel / ReadOnlyAttribute.cs
1 //
2 // ReadOnlyAttribute.cs
3 //
4 // Author:
5 //   Chris J Breisch (cjbreisch@altavista.net)
6 //
7 // (C) 2002 Chris J Breisch
8 //
9 namespace System.ComponentModel {
10         [AttributeUsage (AttributeTargets.All)]
11         sealed public class ReadOnlyAttribute : Attribute {
12                 bool read_only;
13                 
14                 public static readonly ReadOnlyAttribute No;
15                 public static readonly ReadOnlyAttribute Yes;
16                 public static readonly ReadOnlyAttribute Default;
17
18                 static ReadOnlyAttribute ()
19                 {
20                         No = new ReadOnlyAttribute (false);
21                         Yes = new ReadOnlyAttribute (true);
22                         Default = new ReadOnlyAttribute (false);
23                 }
24                 
25                 public ReadOnlyAttribute (bool read_only)
26                 {
27                         this.read_only = read_only;
28                 }
29
30                 public bool IsReadOnly {
31                         get {
32                                 return read_only;
33                         }
34                 }
35
36                 public override int GetHashCode ()
37                 {
38                         return base.GetHashCode ();
39                 }
40
41                 public override bool Equals (object o)
42                 {
43                         if (!(o is ReadOnlyAttribute))
44                                 return false;
45
46                         return (((ReadOnlyAttribute) o).read_only == read_only);
47                 }
48
49                 public override bool IsDefaultAttribute ()
50                 {
51                         return Equals (Default);
52                 }
53         }
54 }