2 // System.ComponentModel.PropertyTabAttribute
5 // Martin Willemoes Hansen (mwh@sysrq.dk)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 // (C) 2003 Martin Willemoes Hansen
9 // (C) 2003 Andreas Nahr
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 namespace System.ComponentModel
35 [AttributeUsage(AttributeTargets.All)]
36 public class PropertyTabAttribute : Attribute
40 private PropertyTabScope[] scopes;
43 public PropertyTabAttribute()
49 public PropertyTabAttribute (string tabClassName)
51 string[] tabArray = {tabClassName};
52 this.InitializeArrays (tabArray, null);
55 public PropertyTabAttribute (Type tabClass)
57 Type[] tabArray = {tabClass};
58 this.InitializeArrays (tabArray, null);
61 public PropertyTabAttribute (string tabClassName, PropertyTabScope tabScope)
63 string[] tabArray = {tabClassName};
64 PropertyTabScope[] scopeArray = {tabScope};
65 this.InitializeArrays (tabArray, scopeArray);
68 public PropertyTabAttribute (Type tabClass, PropertyTabScope tabScope)
70 Type[] tabArray = {tabClass};
71 PropertyTabScope[] scopeArray = {tabScope};
72 this.InitializeArrays (tabArray, scopeArray);
75 public Type[] TabClasses {
79 public PropertyTabScope[] TabScopes {
80 get { return scopes; }
83 public override bool Equals (object other)
85 if (!(other is PropertyTabAttribute))
89 return ((PropertyTabAttribute) other).TabClasses == tabs &&
90 ((PropertyTabAttribute) other).TabScopes == scopes;
93 public bool Equals (PropertyTabAttribute other)
95 return this.Equals ((object) other);
98 public override int GetHashCode()
100 // FIXME check if other Hashcode is needed
101 return base.GetHashCode ();
104 protected string[] TabClassNames {
106 // FIXME untested, maybe wrong
107 string[] tabClassName = (string[]) (Array.CreateInstance (typeof (string), tabs.Length));
108 for (int x = 0; x < tabs.Length; x++)
109 tabClassName[x] = tabs[x].AssemblyQualifiedName;
114 protected void InitializeArrays (string[] tabClassNames, PropertyTabScope[] tabScopes)
116 // FIXME untested, maybe wrong
117 Type[] tabClasses = (Type[]) (Array.CreateInstance (typeof (Type), tabClassNames.Length));
118 for (int x = 0; x < tabClassNames.Length; x++)
119 tabClasses[x] = Type.GetType (tabClassNames[x], false);
125 protected void InitializeArrays (Type[] tabClasses, PropertyTabScope[] tabScopes)
127 // FIXME untested, maybe wrong