2 // System.ComponentModel.DesignerAttribute.cs
5 // Alejandro Sánchez Acosta (raciel@es.gnu.org)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 // (C) Alejandro Sánchez Acosta
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 using System
.ComponentModel
.Design
;
35 namespace System
.ComponentModel
39 /// Designer Attribute for classes.
41 [AttributeUsage(AttributeTargets
.Class
| AttributeTargets
.Interface
, AllowMultiple
= true, Inherited
= true)]
42 public sealed class DesignerAttribute
: Attribute
45 private string basetypename
;
47 public DesignerAttribute (string designerTypeName
)
49 if (designerTypeName
== null)
50 throw new NullReferenceException ();
51 name
= designerTypeName
;
52 basetypename
= typeof(IDesigner
).FullName
;
55 public DesignerAttribute (Type designerType
)
56 : this (designerType
.AssemblyQualifiedName
)
60 public DesignerAttribute (string designerTypeName
, Type designerBaseType
)
61 : this (designerTypeName
, designerBaseType
.AssemblyQualifiedName
)
65 public DesignerAttribute (Type designerType
, Type designerBaseType
)
66 : this (designerType
.AssemblyQualifiedName
, designerBaseType
.AssemblyQualifiedName
)
70 public DesignerAttribute (string designerTypeName
, string designerBaseTypeName
)
72 if (designerTypeName
== null)
73 throw new NullReferenceException ();
74 name
= designerTypeName
;
75 basetypename
= designerBaseTypeName
;
78 public string DesignerBaseTypeName
{
84 public string DesignerTypeName
{
90 public override object TypeId
{
92 string baseTypeNameOnly
= basetypename
;
93 int index
= baseTypeNameOnly
.IndexOf (',');
94 if (index
!= -1) // strip name
95 baseTypeNameOnly
= baseTypeNameOnly
.Substring (0, index
);
96 return this.GetType ().ToString() + baseTypeNameOnly
;
100 public override bool Equals (object obj
)
102 if (!(obj
is DesignerAttribute
))
104 return ((DesignerAttribute
) obj
).DesignerBaseTypeName
.Equals (basetypename
) &&
105 ((DesignerAttribute
) obj
).DesignerTypeName
.Equals (name
);
108 public override int GetHashCode ()
110 return string.Concat(name
, basetypename
).GetHashCode ();