Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/11/10 03:50:29 (15 years ago)
Author:
swagner
Message:

Fixed exception handling in TypeSelector (#906)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs

    r2953 r2999  
    128128                  typeNode.ImageIndex = imageList.Images.IndexOfKey(type.FullName);
    129129                }
    130                 catch (Exception) {
    131                 }
     130                catch (Exception) { }
    132131              }
    133132              typeNode.SelectedImageIndex = typeNode.ImageIndex;
     
    199198
    200199    public virtual object CreateInstanceOfSelectedType(params object[] args) {
    201       if (SelectedType != null) {
    202       try {
     200      if (SelectedType == null)
     201        throw new InvalidOperationException("No type selected.");
     202      else
    203203        return Activator.CreateInstance(SelectedType, args);
    204       } catch(Exception) { }
    205       }
    206       return null;
    207204    }
    208205
     
    248245      TreeNode node = (TreeNode)e.Item;
    249246      Type type = node.Tag as Type;
    250       if (type != null) {
    251         try {
    252           object o = Activator.CreateInstance(type);
    253           DataObject data = new DataObject();
    254           data.SetData("Type", type);
    255           data.SetData("Value", o);
    256           DoDragDrop(data, DragDropEffects.Copy);
    257         } catch (Exception) {
    258         }
     247      if ((type != null) && (!type.IsInterface) && (!type.IsAbstract) && (!type.HasElementType) && (!type.ContainsGenericParameters)) {
     248        object o = Activator.CreateInstance(type);
     249        DataObject data = new DataObject();
     250        data.SetData("Type", type);
     251        data.SetData("Value", o);
     252        DoDragDrop(data, DragDropEffects.Copy);
    259253      }
    260254    }
Note: See TracChangeset for help on using the changeset viewer.