Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/20/09 16:22:27 (15 years ago)
Author:
mkommend
Message:

refactored MainFormManager to use linq syntax (ticket #771)

File:
1 edited

Legend:

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

    r2443 r2444  
    4444
    4545          DiscoveryService ds = new DiscoveryService();
    46           Type[] types = ds.GetTypes(typeof(IView));
     46          IEnumerable<Type> types =
     47            from t in ds.GetTypes(typeof(IView))
     48            where !t.IsAbstract && !t.IsInterface && !t.IsGenericType
     49            select t;
    4750
    48           foreach (Type t in types.Where(t => !t.IsAbstract && !t.IsInterface && !t.IsGenericType)) {
     51          foreach (Type t in types) {
    4952            foreach (Type viewableType in GetViewableType(t)) {
    5053              if (viewableType != null) {
     
    6972
    7073    private static IEnumerable<Type> GetViewableType(Type t) {
    71       foreach (Type interfaceType in t.GetInterfaces().Where(i => i.Namespace == "HeuristicLab.MainForm" && i.Name.StartsWith("IView"))) {
    72         if (interfaceType.IsGenericType && !interfaceType.IsGenericTypeDefinition)
     74      IEnumerable<Type> interfaceTypes =
     75       from type in t.GetInterfaces()
     76       where type.Namespace == "HeuristicLab.MainForm" && type.Name.StartsWith("IView")  &&
     77             type.IsGenericType && !type.IsGenericTypeDefinition
     78       select type;
     79
     80      foreach (Type interfaceType in interfaceTypes) {     
    7381          yield return interfaceType.GetGenericArguments()[0];
    7482      }
     
    100108        return defaultViews[viewableType];
    101109      else {
    102         List<Type> temp = defaultViews.Keys.Where(x => x.IsAssignableFrom(viewableType)).ToList();
     110        List<Type> temp = (from t in defaultViews.Keys
     111                           where t.IsAssignableFrom(viewableType)
     112                           select t).ToList();
    103113        //no assignable type found
    104114        if (temp.Count == 0)
Note: See TracChangeset for help on using the changeset viewer.