Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5631


Ignore:
Timestamp:
03/08/11 11:55:09 (14 years ago)
Author:
gkronber
Message:

#1429: added check to prevent instantiation of IApplications in disabled plugins but successfully loaded assemblies.

File:
1 edited

Legend:

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

    r5629 r5631  
    141141
    142142      plugins = pluginDescriptions;
    143       DiscoverApplications();
    144     }
    145 
    146     private void DiscoverApplications() {
     143      DiscoverApplications(pluginDescriptions);
     144    }
     145
     146    private void DiscoverApplications(IEnumerable<PluginDescription> pluginDescriptions) {
    147147      applications = new List<ApplicationDescription>();
    148 
    149       foreach (IApplication application in GetApplications()) {
     148      foreach (IApplication application in GetApplications(pluginDescriptions)) {
    150149        Type appType = application.GetType();
    151150        ApplicationAttribute attr = (from x in appType.GetCustomAttributes(typeof(ApplicationAttribute), false)
    152151                                     select (ApplicationAttribute)x).Single();
    153         var declaringPlugin = GetDeclaringPlugin(appType, plugins);
    154152        ApplicationDescription info = new ApplicationDescription();
     153        PluginDescription declaringPlugin = GetDeclaringPlugin(appType, pluginDescriptions);
    155154        info.Name = application.Name;
    156155        info.Version = declaringPlugin.Version;
     
    164163    }
    165164
    166     private static IEnumerable<IApplication> GetApplications() {
     165    private static IEnumerable<IApplication> GetApplications(IEnumerable<PluginDescription> pluginDescriptions) {
    167166      return from asm in AppDomain.CurrentDomain.GetAssemblies()
    168167             from t in asm.GetTypes()
    169168             where typeof(IApplication).IsAssignableFrom(t) &&
    170169               !t.IsAbstract && !t.IsInterface && !t.HasElementType
     170             where GetDeclaringPlugin(t, pluginDescriptions).PluginState != PluginState.Disabled
    171171             select (IApplication)Activator.CreateInstance(t);
    172172    }
     
    597597    }
    598598
    599     private PluginDescription GetDeclaringPlugin(Type appType, IEnumerable<PluginDescription> plugins) {
     599    private static PluginDescription GetDeclaringPlugin(Type appType, IEnumerable<PluginDescription> plugins) {
    600600      return (from p in plugins
    601601              from asmLocation in p.AssemblyLocations
Note: See TracChangeset for help on using the changeset viewer.