Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/28/11 19:12:31 (13 years ago)
Author:
mkommend
Message:

#1454: Implemented TypeDiscovery with multiple base types and adapted TypeSelector and CrossValidation.

File:
1 edited

Legend:

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

    r5741 r5850  
    8282    }
    8383
    84 
    85     /// <summary>
    86     /// Finds all instantiable types that are subtypes or equal to the specified type.
    87     /// </summary>
    88     /// <param name="type">Most general type for which to find matching types.</param>
     84    /// <summary>
     85    /// Finds all instantiable types that are subtypes or equal to the specified types.
     86    /// </summary>
     87    /// <param name="types">Most general types for which to find matching types.</param>
    8988    /// <remarks>Return only types that are instantiable
    9089    /// (interfaces, abstract classes... are not returned)</remarks>
    9190    /// <returns>Enumerable of the discovered types.</returns>
    92     public IEnumerable<Type> GetTypes(Type type) {
    93       return GetTypes(type, true);
     91    public IEnumerable<Type> GetTypes(IEnumerable<Type> types, bool onlyInstantiable = true, bool allTypes = true) {
     92      IEnumerable<Type> result = GetTypes(types.First(), onlyInstantiable);
     93      foreach (Type type in types.Skip(1)) {
     94        IEnumerable<Type> discoveredTypes = GetTypes(type, onlyInstantiable);
     95        if (allTypes) result = result.Intersect(discoveredTypes);
     96        else result = result.Union(discoveredTypes);
     97      }
     98
     99      if (!allTypes) return result.Distinct();
     100      return result;
    94101    }
    95102
     
    101108    /// (interfaces, abstract classes... are not returned)</param>
    102109    /// <returns>Enumerable of the discovered types.</returns>
    103     public IEnumerable<Type> GetTypes(Type type, bool onlyInstantiable) {
     110    public IEnumerable<Type> GetTypes(Type type, bool onlyInstantiable = true) {
    104111      return from asm in AppDomain.CurrentDomain.GetAssemblies()
    105112             from t in GetTypes(type, asm, onlyInstantiable)
     
    115122    /// (interfaces, abstract classes...  are not returned)</param>
    116123    /// <returns>Enumerable of the discovered types.</returns>
    117     private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable) {
     124    private static IEnumerable<Type> GetTypes(Type type, Assembly assembly, bool onlyInstantiable = true) {
    118125      try {
    119126        var assemblyTypes = assembly.GetTypes();
     
    175182    /// <returns></returns>
    176183    /// <throws>NotSupportedException</throws>
    177     public IEnumerable<Type> GetTypes(Type type, IPluginDescription plugin, bool onlyInstantiable) {
     184    public IEnumerable<Type> GetTypes(Type type, IPluginDescription plugin, bool onlyInstantiable = true) {
     185      throw new NotSupportedException("LightweightApplicationManager doesn't support type discovery for plugins.");
     186    }
     187
     188    /// <summary>
     189    /// Not supported by the LightweightApplicationManager
     190    /// </summary>
     191    /// <param name="type"></param>
     192    /// <param name="plugin"></param>
     193    /// <param name="onlyInstantiable"></param>
     194    /// <returns></returns>
     195    /// <throws>NotSupportedException</throws>
     196    public IEnumerable<Type> GetTypes(IEnumerable<Type> types, IPluginDescription plugin, bool onlyInstantiable = true, bool allTypes = true) {
    178197      throw new NotSupportedException("LightweightApplicationManager doesn't support type discovery for plugins.");
    179198    }
Note: See TracChangeset for help on using the changeset viewer.