Changeset 11975 for branches/ALPS/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs
- Timestamp:
- 02/10/15 09:57:29 (10 years ago)
- Location:
- branches/ALPS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS
- Property svn:mergeinfo changed
-
branches/ALPS/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs
r11171 r11975 260 260 /// <param name="includeGenericTypeDefinitions">Specifies if generic type definitions shall be included</param> 261 261 /// <returns>Enumerable of the discovered types.</returns> 262 privatestatic IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable, bool includeGenericTypeDefinitions) {262 internal static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable, bool includeGenericTypeDefinitions) { 263 263 var matchingTypes = from assemblyType in assembly.GetTypes() 264 264 let t = assemblyType.BuildType(type) … … 273 273 } 274 274 275 /// <summary> 276 /// Discovers all types implementing or inheriting all or any type in <paramref name="types"/> (directly and indirectly) that are declared in the assembly <paramref name="assembly"/>. 277 /// </summary> 278 /// <param name="types">The types to discover.</param> 279 /// <param name="assembly">The declaring assembly.</param> 280 /// <param name="onlyInstantiable">Return only types that are instantiable (instance, abstract... are not returned)</param> 281 /// /// <param name="assignableToAllTypes">Specifies if discovered types must implement or inherit all given <paramref name="types"/>.</param> 282 /// <returns>An enumerable of discovered types.</returns> 283 internal static IEnumerable<Type> GetTypes(IEnumerable<Type> types, Assembly assembly, bool onlyInstantiable = true, bool includeGenericTypeDefinitions = false, bool assignableToAllTypes = true) { 284 IEnumerable<Type> result = GetTypes(types.First(), assembly, onlyInstantiable, includeGenericTypeDefinitions); 285 foreach (Type type in types.Skip(1)) { 286 IEnumerable<Type> discoveredTypes = GetTypes(type, assembly, onlyInstantiable, includeGenericTypeDefinitions); 287 if (assignableToAllTypes) result = result.Intersect(discoveredTypes); 288 else result = result.Union(discoveredTypes); 289 } 290 return result; 291 } 292 275 293 private void OnPluginLoaded(PluginInfrastructureEventArgs e) { 276 294 if (PluginLoaded != null) PluginLoaded(this, e); … … 303 321 IEnumerable<Type> IApplicationManager.GetTypes(IEnumerable<Type> types, IPluginDescription plugin, bool onlyInstantiable, bool includeGenericTypeDefinitions, bool assignableToAllTypes) { 304 322 return GetTypes(types, plugin, onlyInstantiable, includeGenericTypeDefinitions, assignableToAllTypes); 323 } 324 325 IEnumerable<Type> IApplicationManager.GetTypes(Type type, Assembly assembly, bool onlyInstantiable, bool includeGenericTypeDefinitions) { 326 return GetTypes(type, assembly, onlyInstantiable, includeGenericTypeDefinitions); 327 } 328 IEnumerable<Type> IApplicationManager.GetTypes(IEnumerable<Type> types, Assembly assembly, bool onlyInstantiable, bool includeGenericTypeDefinitions, bool assignableToAllTypes) { 329 return GetTypes(types, assembly, onlyInstantiable, includeGenericTypeDefinitions, assignableToAllTypes); 305 330 } 306 331
Note: See TracChangeset
for help on using the changeset viewer.