public override object GetEditor(Type editorBaseType) {
object editor = null;
// Check the editors we've already created for this type.
//
if (editorTypes != null) {
for (int i = 0; i < editorCount; i++) {
if (editorTypes[i] == editorBaseType) {
return editors[i];
}
}
}
// If one wasn't found, then we must go through the attributes.
//
if (editor == null) {
for (int i = 0; i < Attributes.Count; i++) {
if (!(Attributes[i] is EditorAttribute)) {
continue;
}
EditorAttribute attr = (EditorAttribute)Attributes[i];
Type editorType = GetTypeFromName(attr.EditorBaseTypeName);
if (editorBaseType == editorType) {
Type type = GetTypeFromName(attr.EditorTypeName);
if (type != null) {
editor = CreateInstance(type);
break;
}
}
}
// Now, if we failed to find it in our own attributes, go to the
// component descriptor.
//
if (editor == null) {
editor = DebugTypeDescriptor.GetEditor(PropertyType, editorBaseType);
}
// Now, another slot in our editor cache for next time
//
if (editorTypes == null) {
editorTypes = new Type[5];
editors = new object[5];
}
if (editorCount >= editorTypes.Length) {
Type[] newTypes = new Type[editorTypes.Length * 2];
object[] newEditors = new object[editors.Length * 2];
Array.Copy(editorTypes, newTypes, editorTypes.Length);
Array.Copy(editors, newEditors, editors.Length);
editorTypes = newTypes;
editors = newEditors;
}
editorTypes[editorCount] = editorBaseType;
editors[editorCount++] = editor;
}
return editor;
}