Changeset 7520 for trunk/sources/HeuristicLab.PluginInfrastructure
- Timestamp:
- 02/24/12 14:04:43 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/LightweightApplicationManager.cs
r7492 r7520 75 75 foreach (Type t in GetTypes(type)) { 76 76 object instance = null; 77 try { instance = Activator.CreateInstance(t); } 78 catch { } 77 try { instance = Activator.CreateInstance(t); } catch { } 79 78 if (instance != null) instances.Add(instance); 80 79 } … … 127 126 128 127 var buildTypes = from t in assembly.GetTypes() 128 where CheckTypeCompatibility(type, t) 129 129 where !IsNonDiscoverableType(t) 130 130 where onlyInstantiable == false || 131 131 (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 132 where CheckTypeCompatibility(type, t)133 132 select BuildType(t, type); 134 133 … … 136 135 where includeGenericTypeDefinitions || !t.IsGenericTypeDefinition 137 136 select t; 138 } 139 catch (TypeLoadException) { 137 } catch (TypeLoadException) { 140 138 return Enumerable.Empty<Type>(); 141 } 142 catch (ReflectionTypeLoadException) { 139 } catch (ReflectionTypeLoadException) { 143 140 return Enumerable.Empty<Type>(); 144 141 } … … 174 171 if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments))) 175 172 return true; 176 } 177 catch (Exception) { } 173 } catch (Exception) { } 178 174 } 179 175 return false; -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs
r7502 r7520 119 119 try { 120 120 runnablePlugin.Run(); 121 } 122 finally { 121 } finally { 123 122 // unload plugins in reverse order 124 123 foreach (var plugin in loadedPlugins.Reverse<IPlugin>()) { … … 150 149 foreach (Type t in GetTypes(typeof(T), plugin, onlyInstantiable: true, includeGenericTypeDefinitions: false)) { 151 150 T instance = null; 152 try { instance = (T)Activator.CreateInstance(t); } 153 catch { } 151 try { instance = (T)Activator.CreateInstance(t); } catch { } 154 152 if (instance != null) instances.Add(instance); 155 153 } … … 166 164 foreach (Type t in GetTypes(typeof(T), asm, onlyInstantiable: true, includeGenericTypeDefinitions: false)) { 167 165 T instance = null; 168 try { instance = (T)Activator.CreateInstance(t); } 169 catch { } 166 try { instance = (T)Activator.CreateInstance(t); } catch { } 170 167 if (instance != null) instances.Add(instance); 171 168 } … … 191 188 foreach (Type t in GetTypes(type, onlyInstantiable: true, includeGenericTypeDefinitions: false)) { 192 189 object instance = null; 193 try { instance = Activator.CreateInstance(t); } 194 catch { } 190 try { instance = Activator.CreateInstance(t); } catch { } 195 191 if (instance != null) instances.Add(instance); 196 192 } … … 262 258 private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable, bool includeGenericTypeDefinitions) { 263 259 var buildTypes = from t in assembly.GetTypes() 260 where CheckTypeCompatibility(type, t) 264 261 where !IsNonDiscoverableType(t) 265 262 where onlyInstantiable == false || 266 263 (!t.IsAbstract && !t.IsInterface && !t.HasElementType) 267 where CheckTypeCompatibility(type, t)268 264 select BuildType(t, type); 269 265 … … 303 299 if (type.IsAssignableFrom(otherGenericTypeDefinition.MakeGenericType(typeGenericArguments))) 304 300 return true; 305 } 306 catch (Exception) { } 301 } catch (Exception) { } 307 302 } 308 303 return false;
Note: See TracChangeset
for help on using the changeset viewer.