2002-07-12 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI / ParseChildrenAttribute.cs
1 //
2 // System.Web.UI.ParseChildrenAttribute.cs
3 //
4 // Authors:
5 //      Duncan Mak  (duncan@ximian.com)
6 //      Gonzalo Paniagua (gonzalo@ximian.com)
7 //
8 // (C) 2002 Ximian, Inc. (http://www.ximian.com
9 //
10
11 using System;
12
13 namespace System.Web.UI {
14
15         [AttributeUsage (AttributeTargets.Class)]
16         public sealed class ParseChildrenAttribute : Attribute
17         {
18                 bool childrenAsProperties;
19                 string defaultProperty;
20                 public static readonly ParseChildrenAttribute Default = new ParseChildrenAttribute ();
21
22                 // LAMESPEC
23                 public ParseChildrenAttribute ()
24                 {
25                         childrenAsProperties = false;
26                         defaultProperty = "";
27                 }
28
29                 public ParseChildrenAttribute (bool childrenAsProperties)
30                 {
31                         this.childrenAsProperties = childrenAsProperties;
32                         this.defaultProperty = "";
33                 }
34
35                 public ParseChildrenAttribute (bool childrenAsProperties,
36                                                string defaultProperty)
37                 {
38                         this.childrenAsProperties = childrenAsProperties;
39                         if (childrenAsProperties)
40                                 this.defaultProperty = defaultProperty;
41                 }
42
43                 public bool ChildrenAsProperties {
44
45                         get { return childrenAsProperties; }
46
47                         set { childrenAsProperties = value; }
48                 }
49
50                 public string DefaultProperty {
51                         get { return defaultProperty; }
52
53                         set { defaultProperty = value; }
54                 }
55
56                 public override bool Equals (object obj)
57                 {
58                         if (!(obj is ParseChildrenAttribute))
59                                 return false;
60
61                         ParseChildrenAttribute o = (ParseChildrenAttribute) obj;
62                         if (childrenAsProperties == o.childrenAsProperties){
63                                 if (childrenAsProperties == false)
64                                         return true;
65                                 return (defaultProperty == o.DefaultProperty);
66                         }
67                         return false;
68                 }
69
70                 public override int GetHashCode ()
71                 {
72                         return base.GetHashCode ();
73                 }
74
75                 public override bool IsDefaultAttribute ()
76                 {
77                         return Equals (Default);
78                 }
79         }
80 }