Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/24/12 14:04:43 (13 years ago)
Author:
abeham
Message:

#1774:

  • improved performance of type discovery by moving compatibility check further up the chain (deep cloneable unit test time reduced from 32s to 18s)
Location:
trunk/sources/HeuristicLab.PluginInfrastructure/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs

    r7492 r7520  
    7575      foreach (Type t in GetTypes(type)) {
    7676        object instance = null;
    77         try { instance = Activator.CreateInstance(t); }
    78         catch { }
     77        try { instance = Activator.CreateInstance(t); } catch { }
    7978        if (instance != null) instances.Add(instance);
    8079      }
     
    127126
    128127        var buildTypes = from t in assembly.GetTypes()
     128                         where CheckTypeCompatibility(type, t)
    129129                         where !IsNonDiscoverableType(t)
    130130                         where onlyInstantiable == false ||
    131131                               (!t.IsAbstract && !t.IsInterface && !t.HasElementType)
    132                          where CheckTypeCompatibility(type, t)
    133132                         select BuildType(t, type);
    134133
     
    136135               where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition
    137136               select t;
    138       }
    139       catch (TypeLoadException) {
     137      } catch (TypeLoadException) {
    140138        return Enumerable.Empty<Type>();
    141       }
    142       catch (ReflectionTypeLoadException) {
     139      } catch (ReflectionTypeLoadException) {
    143140        return Enumerable.Empty<Type>();
    144141      }
     
    174171          if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments)))
    175172            return true;
    176         }
    177         catch (Exception) { }
     173        } catch (Exception) { }
    178174      }
    179175      return false;
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs

    r7502 r7520  
    119119      try {
    120120        runnablePlugin.Run();
    121       }
    122       finally {
     121      } finally {
    123122        // unload plugins in reverse order
    124123        foreach (var plugin in loadedPlugins.Reverse<IPlugin>()) {
     
    150149      foreach (Type t in GetTypes(typeof(T), plugin, onlyInstantiable: true, includeGenericTypeDefinitions: false)) {
    151150        T instance = null;
    152         try { instance = (T)Activator.CreateInstance(t); }
    153         catch { }
     151        try { instance = (T)Activator.CreateInstance(t); } catch { }
    154152        if (instance != null) instances.Add(instance);
    155153      }
     
    166164      foreach (Type t in GetTypes(typeof(T), asm, onlyInstantiable: true, includeGenericTypeDefinitions: false)) {
    167165        T instance = null;
    168         try { instance = (T)Activator.CreateInstance(t); }
    169         catch { }
     166        try { instance = (T)Activator.CreateInstance(t); } catch { }
    170167        if (instance != null) instances.Add(instance);
    171168      }
     
    191188      foreach (Type t in GetTypes(type, onlyInstantiable: true, includeGenericTypeDefinitions: false)) {
    192189        object instance = null;
    193         try { instance = Activator.CreateInstance(t); }
    194         catch { }
     190        try { instance = Activator.CreateInstance(t); } catch { }
    195191        if (instance != null) instances.Add(instance);
    196192      }
     
    262258    private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable, bool includeGenericTypeDefinitions) {
    263259      var buildTypes = from t in assembly.GetTypes()
     260                       where CheckTypeCompatibility(type, t)
    264261                       where !IsNonDiscoverableType(t)
    265262                       where onlyInstantiable == false ||
    266263                             (!t.IsAbstract && !t.IsInterface && !t.HasElementType)
    267                        where CheckTypeCompatibility(type, t)
    268264                       select BuildType(t, type);
    269265
     
    303299          if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments)))
    304300            return true;
    305         }
    306         catch (Exception) { }
     301        } catch (Exception) { }
    307302      }
    308303      return false;
Note: See TracChangeset for help on using the changeset viewer.