Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/18/09 01:18:23 (15 years ago)
Author:
mkommend
Message:

minor code refactoring (ticket #771)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Mainform refactoring/HeuristicLab.MainForm/3.2/MainFormManager.cs

    r2437 r2438  
    9797
    9898    public static Type GetDefaultViewType(Type viewableType) {
    99       if (!defaultViews.ContainsKey(viewableType)) {
     99      if (defaultViews.ContainsKey(viewableType))
     100        return defaultViews[viewableType];
     101      else {
    100102        List<Type> temp = defaultViews.Keys.Where(x => x.IsAssignableFrom(viewableType)).ToList();
     103        //no assignable type found
    101104        if (temp.Count == 0)
    102105          return null;
     106        //only one assignable type found => return this one
    103107        else if (temp.Count == 1)
    104108          return defaultViews[temp[0]];
     109        //more assignable types found => sort the types according to their assignable types
     110        //and return most specific type => except there is a conflict
    105111        else {
    106112          temp.Sort(delegate(Type t1, Type t2) {
     
    110116          }
    111117          );
    112           if (!temp[0].IsAssignableFrom(temp[1]) && !temp[1].IsAssignableFrom(temp[0]))
     118          if (temp[1].IsAssignableFrom(temp[0]))
     119            return defaultViews[temp[0]];
     120          else
    113121            throw new Exception("Could not determine which is the default view for type " + viewableType.ToString() + ".");
    114           else
    115             return defaultViews[temp[0]];
    116122        }
    117       } else
    118         return defaultViews[viewableType];
     123      }     
    119124    }
    120125
Note: See TracChangeset for help on using the changeset viewer.