1 //------------------------------------------------------------------------------
2 // <copyright file="EditorAttribute.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //------------------------------------------------------------------------------
9 namespace System.ComponentModel {
11 using System.Diagnostics;
12 using System.Globalization;
15 /// <para>Specifies the editor to use to change a property. This class cannot be inherited.</para>
17 [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
18 public sealed class EditorAttribute : Attribute {
20 private string baseTypeName;
21 private string typeName;
22 private string typeId;
25 /// <para>Initializes a new instance of the <see cref='System.ComponentModel.EditorAttribute'/> class with the default editor, which is
28 public EditorAttribute() {
29 this.typeName = string.Empty;
30 this.baseTypeName = string.Empty;
34 /// <para>Initializes a new instance of the <see cref='System.ComponentModel.EditorAttribute'/> class with the type name and base type
35 /// name of the editor.</para>
37 public EditorAttribute(string typeName, string baseTypeName) {
38 string temp = typeName.ToUpperInvariant ();
39 Debug.Assert(temp.IndexOf(".DLL") == -1, "Came across: " + typeName + " . Please remove the .dll extension");
40 this.typeName = typeName;
41 this.baseTypeName = baseTypeName;
45 /// <para>Initializes a new instance of the <see cref='System.ComponentModel.EditorAttribute'/> class.</para>
47 public EditorAttribute(string typeName, Type baseType) {
48 string temp = typeName.ToUpperInvariant ();
49 Debug.Assert(temp.IndexOf(".DLL") == -1, "Came across: " + typeName + " . Please remove the .dll extension");
50 this.typeName = typeName;
51 this.baseTypeName = baseType.AssemblyQualifiedName;
55 /// <para>Initializes a new instance of the <see cref='System.ComponentModel.EditorAttribute'/>
58 public EditorAttribute(Type type, Type baseType) {
59 this.typeName = type.AssemblyQualifiedName;
60 this.baseTypeName = baseType.AssemblyQualifiedName;
64 /// <para>Gets the name of the base class or interface serving as a lookup key for this editor.</para>
66 public string EditorBaseTypeName {
73 /// <para>Gets the name of the editor class.</para>
75 public string EditorTypeName {
84 /// This defines a unique ID for this attribute type. It is used
85 /// by filtering algorithms to identify two attributes that are
86 /// the same type. For most attributes, this just returns the
87 /// Type instance for the attribute. EditorAttribute overrides
88 /// this to include the type of the editor base type.
91 public override object TypeId {
94 string baseType = baseTypeName;
95 int comma = baseType.IndexOf(',');
97 baseType = baseType.Substring(0, comma);
99 typeId = GetType().FullName + baseType;
105 public override bool Equals(object obj) {
110 EditorAttribute other = obj as EditorAttribute;
112 return (other != null) && other.typeName == typeName && other.baseTypeName == baseTypeName;
115 public override int GetHashCode() {
116 return base.GetHashCode();