protected override sealed object CreateInstance(Type itemType) { string name = RunTimeUIEdTools.BaseNameFromType(itemType); object objectValue = RuntimeHelpers.GetObjectValue(base.CreateInstance(itemType)); PropertyInfo property = objectValue.GetType().GetProperty("Name"); if ((uint)this.NameService > 0U) { if ((object)property == null) { this.DisplayError("[Name] property must be implemented to use the NamingService"); return(objectValue); } if (!property.CanWrite) { this.DisplayError("[Name] property cannot be Read-Only using NamingService"); return(objectValue); } } switch (this.NameService) { case NameServices.Automatic: NewItemCreatedEventArgs e = new NewItemCreatedEventArgs(name); // ISSUE: reference to a compiler-generated field //EnhancedCollectionEditor.NewItemCreatedEventHandler itemCreatedEvent = this.NewItemCreatedEvent; //if (itemCreatedEvent != null) // itemCreatedEvent((object)this, e); //string newName = this.GetNewName(e.ItemBaseName); //property.SetValue(RuntimeHelpers.GetObjectValue(objectValue), (object)newName, (object[])null); break; case NameServices.NameProvider: string nameFromProvider = this.GetNameFromProvider(itemType); property.SetValue(RuntimeHelpers.GetObjectValue(objectValue), (object)nameFromProvider, (object[])null); break; } return(objectValue); }
public static string BaseNameFromType(Type ItemType) { return(RunTimeUIEdTools.BaseNameFromTypeName(ItemType.ToString())); }