Changeset 5848 for trunk/sources
- Timestamp:
- 03/28/11 18:07:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs
r5837 r5848 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Reflection; 25 26 using System.Text; 26 27 using System.Windows.Forms; … … 114 115 pluginNode.Tag = plugin; 115 116 116 var types = from t in ApplicationManager.Manager.GetTypes(BaseType, plugin, false)117 var types = from t in ApplicationManager.Manager.GetTypes(BaseType, plugin, ShowNotInstantiableTypes) 117 118 orderby t.Name ascending 118 119 select t; … … 120 121 bool valid = true; 121 122 valid = valid && (ShowGenericTypes || !type.ContainsGenericParameters); 122 valid = valid && (ShowNotInstantiableTypes || !type.IsAbstract);123 valid = valid && (ShowNotInstantiableTypes || !type.IsInterface);124 valid = valid && (ShowNotInstantiableTypes || !type.HasElementType);125 123 valid = valid && (ShowNotInstantiableTypes || type.GetConstructor(Type.EmptyTypes) != null); //check for public default ctor 126 124 if (valid) { … … 132 130 else if (type.ContainsGenericParameters) typeNode.ImageIndex = 3; 133 131 else if (imageList.Images.ContainsKey(type.FullName)) typeNode.ImageIndex = imageList.Images.IndexOfKey(type.FullName); 134 else if (typeof(IItem).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract) { 135 try { 136 IItem item = (IItem)Activator.CreateInstance(type); 137 imageList.Images.Add(type.FullName, item.ItemImage); 138 typeNode.ImageIndex = imageList.Images.IndexOfKey(type.FullName); 139 } 140 catch (Exception) { } 132 else if (typeof(IItem).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract && type.GetConstructor(Type.EmptyTypes) != null) { 133 IItem item = (IItem)Activator.CreateInstance(type); 134 imageList.Images.Add(type.FullName, item.ItemImage); 135 typeNode.ImageIndex = imageList.Images.IndexOfKey(type.FullName); 141 136 } 142 137 typeNode.SelectedImageIndex = typeNode.ImageIndex; … … 258 253 Type param = typeParametersListView.SelectedItems[0].Tag as Type; 259 254 Type[] contraints = param.GetGenericParameterConstraints(); 260 typeSelectorDialog.TypeSelector.Configure(typeof(IItem), true, true); 255 bool showNotInstantiableTypes = !param.GenericParameterAttributes.HasFlag(GenericParameterAttributes.DefaultConstructorConstraint); 256 typeSelectorDialog.TypeSelector.Configure(typeof(IItem), showNotInstantiableTypes, true); 261 257 262 258 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
Note: See TracChangeset
for help on using the changeset viewer.