Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/ApplicationManager.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/ApplicationManager.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/ApplicationManager.cs	(revision 2488)
@@ -0,0 +1,44 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Security.Policy;
+using System.Reflection;
+using System.Diagnostics;
+using System.Security.Permissions;
+using System.Security;
+using System.Linq;
+
+namespace HeuristicLab.PluginInfrastructure {
+
+  public static class ApplicationManager {
+    private static IApplicationManager appManager;
+    public static IApplicationManager Manager {
+      get { return appManager; }
+    }
+
+    public static void RegisterApplicationManager(IApplicationManager manager) {
+      if (appManager != null) throw new InvalidOperationException("An control manager has already been set.");
+      appManager = manager;
+    }
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/ApplicationAttribute.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/ApplicationAttribute.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/ApplicationAttribute.cs	(revision 2488)
@@ -0,0 +1,109 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HeuristicLab.PluginInfrastructure {
+  /// <summary>
+  /// This attribute can be used to specify meta data for applications. 
+  /// For example to specify name, version and description of applications.
+  /// </summary>
+  [AttributeUsage(AttributeTargets.Class)]
+  public class ApplicationAttribute : System.Attribute {
+    private string name;
+    /// <summary>
+    /// Gets or sets the name of the application.
+    /// </summary>
+    public string Name {
+      get { return name; }
+      set { name = value; }
+    }
+
+    //private string version;
+    ///// <summary>
+    ///// Gets or sets the version of the application.
+    ///// </summary>
+    //public string Version {
+    //  get { return version; }
+    //  set { version = value; }
+    //}
+
+    private string description;
+    /// <summary>
+    /// Gets or sets the description of the application.
+    /// </summary>
+    public string Description {
+      get { return description; }
+      set { description = value; }
+    }
+
+    private bool restartOnErrors;
+    /// <summary>
+    /// Gets or sets the boolean flag whether the plugin should be automatically restarted when it is closed because of an exception (for services).
+    /// </summary>
+    public bool RestartOnErrors {
+      get { return restartOnErrors; }
+      set { restartOnErrors = value; }
+    }
+
+    /// <summary>
+    /// Initializes a new instance of <see cref="ApplicationAttribute"/>.
+    /// <param name="name">Name of the application</param>
+    /// </summary>
+    public ApplicationAttribute(string name)
+      : this(name, "") {
+    }
+
+    /// <summary>
+    /// Initializes a new instance of <see cref="ApplicationAttribute"/>.
+    /// <param name="name">Name of the application</param>
+    /// <param name="description">Description of the application</param>
+    /// </summary>
+    public ApplicationAttribute(string name, string description)
+      : this(name, description, false) {
+    }
+
+    ///// <summary>
+    ///// Initializes a new instance of <see cref="ApplicationAttribute"/>.
+    ///// <param name="name">Name of the application</param>
+    ///// <param name="description">Description of the application</param>
+    ///// <param name="version">Version string of the application</param>
+    ///// </summary>
+    //public ApplicationAttribute(string name, string description, string version)
+    //  : this(name, description, version, false) {
+    //}
+
+    /// <summary>
+    /// Initializes a new instance of <see cref="ApplicationAttribute"/>.
+    /// <param name="name">Name of the application</param>
+    /// <param name="description">Description of the application</param>
+    /// <param name="version">Version string of the application</param>
+    /// <param name="restartOnErrors">Flag that indicates if the application should be restarted on exceptions (for services)</param>
+    /// </summary>
+    public ApplicationAttribute(string name, string description, bool restartOnErrors) {
+      this.name = name;
+      this.description = description;
+      this.restartOnErrors = restartOnErrors;
+    }
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/ApplicationDescriptionAttribute.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/ApplicationDescriptionAttribute.cs	(revision 2481)
+++ 	(revision )
@@ -1,110 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace HeuristicLab.PluginInfrastructure {
-  /// <summary>
-  /// This attribute can be used to specify meta data for applications. 
-  /// For example to specify name, version and description of applications.
-  /// </summary>
-  [AttributeUsage(AttributeTargets.Class)]
-  public class ApplicationDescriptionAttribute : System.Attribute {
-    private string name;
-    /// <summary>
-    /// Gets or sets the name of the application.
-    /// </summary>
-    public string Name {
-      get { return name; }
-      set { name = value; }
-    }
-
-    private string version;
-    /// <summary>
-    /// Gets or sets the version of the application.
-    /// </summary>
-    public string Version {
-      get { return version; }
-      set { version = value; }
-    }
-
-    private string description;
-    /// <summary>
-    /// Gets or sets the description of the application.
-    /// </summary>
-    public string Description {
-      get { return description; }
-      set { description = value; }
-    }
-
-    private bool restartOnErrors;
-    /// <summary>
-    /// Gets or sets the boolean flag whether the plugin should be automatically restarted when it is closed because of an exception (for services).
-    /// </summary>
-    public bool RestartOnErrors {
-      get { return restartOnErrors; }
-      set { restartOnErrors = value; }
-    }
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="ApplicationDescriptionAttribute"/>.
-    /// <param name="name">Name of the application</param>
-    /// </summary>
-    public ApplicationDescriptionAttribute(string name)
-      : this(name, "") {
-    }
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="ApplicationDescriptionAttribute"/>.
-    /// <param name="name">Name of the application</param>
-    /// <param name="description">Description of the application</param>
-    /// </summary>
-    public ApplicationDescriptionAttribute(string name, string description)
-      : this(name, description, "") {
-    }
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="ApplicationDescriptionAttribute"/>.
-    /// <param name="name">Name of the application</param>
-    /// <param name="description">Description of the application</param>
-    /// <param name="version">Version string of the application</param>
-    /// </summary>
-    public ApplicationDescriptionAttribute(string name, string description, string version)
-      : this(name, description, version, false) {
-    }
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="ApplicationDescriptionAttribute"/>.
-    /// <param name="name">Name of the application</param>
-    /// <param name="description">Description of the application</param>
-    /// <param name="version">Version string of the application</param>
-    /// <param name="restartOnErrors">Flag that indicates if the application should be restarted on exceptions (for services)</param>
-    /// </summary>
-    public ApplicationDescriptionAttribute(string name, string description, string version, bool restartOnErrors) {
-      this.name = name;
-      this.version = version;
-      this.description = description;
-      this.restartOnErrors = restartOnErrors;
-    }
-  }
-}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginAttribute.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginAttribute.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginAttribute.cs	(revision 2488)
@@ -0,0 +1,90 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HeuristicLab.PluginInfrastructure {
+  /// <summary>
+  /// This attribute can be used to specify meta data for plugins. 
+  /// For example to specify name, version and description of plugins.
+  /// </summary>
+  [AttributeUsage(AttributeTargets.Class)]
+  public class PluginAttribute : System.Attribute {
+    private string name;
+    /// <summary>
+    /// Gets or sets the name of the plugin.
+    /// </summary>
+    public string Name {
+      get { return name; }
+      // set { name = value; }
+    }
+
+    //private string version;
+    ///// <summary>
+    ///// Gets or sets the version of the plugin.
+    ///// </summary>
+    //public string Version {
+    //  get { return version; }
+    //  set { version = value; }
+    //}
+
+    private string description;
+    /// <summary>
+    /// Gets or sets the description of the plugin.
+    /// </summary>
+    public string Description {
+      get { return description; }
+      // set { description = value; }
+    }
+
+    /// <summary>
+    /// Initializes a new instance of <see cref="PluginAttribute"/>.
+    /// <param name="name">Name of the plugin</param>
+    /// </summary>
+    public PluginAttribute(string name)
+      : this(name, "") {
+    }
+
+    /// <summary>
+    /// Initializes a new instance of <see cref="PluginAttribute"/>.
+    /// <param name="name">Name of the plugin</param>
+    /// <param name="description">Description of the plugin</param>
+    /// </summary>
+    public PluginAttribute(string name, string description) {
+      this.name = name;
+      this.description = description;
+    }
+
+    ///// <summary>
+    ///// Initializes a new instance of <see cref="PluginDescriptionAttribute"/>.
+    ///// <param name="name">Name of the plugin</param>
+    ///// <param name="description">Description of the plugin</param>
+    ///// <param name="version">Version string of the plugin</param>
+    ///// </summary>
+    //public PluginDescriptionAttribute(string name, string description, string version) {
+    //  this.name = name;
+    //  this.version = version;
+    //  this.description = description;
+    //}
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginDescriptionAttribute.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Attributes/PluginDescriptionAttribute.cs	(revision 2481)
+++ 	(revision )
@@ -1,89 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace HeuristicLab.PluginInfrastructure {
-  /// <summary>
-  /// This attribute can be used to specify meta data for plugins. 
-  /// For example to specify name, version and description of plugins.
-  /// </summary>
-  [AttributeUsage(AttributeTargets.Class)]
-  public class PluginDescriptionAttribute : System.Attribute {
-    private string name;
-    /// <summary>
-    /// Gets or sets the name of the plugin.
-    /// </summary>
-    public string Name {
-      get { return name; }
-      // set { name = value; }
-    }
-
-    //private string version;
-    ///// <summary>
-    ///// Gets or sets the version of the plugin.
-    ///// </summary>
-    //public string Version {
-    //  get { return version; }
-    //  set { version = value; }
-    //}
-
-    //private string description;
-    ///// <summary>
-    ///// Gets or sets the description of the plugin.
-    ///// </summary>
-    //public string Description {
-    //  get { return description; }
-    //  set { description = value; }
-    //}
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="PluginDescriptionAttribute"/>.
-    /// <param name="name">Name of the plugin</param>
-    /// </summary>
-    public PluginDescriptionAttribute(string name) {
-      this.name = name;
-    }
-
-    ///// <summary>
-    ///// Initializes a new instance of <see cref="PluginDescriptionAttribute"/>.
-    ///// <param name="name">Name of the plugin</param>
-    ///// <param name="description">Description of the plugin</param>
-    ///// </summary>
-    //public PluginDescriptionAttribute(string name, string description)
-    //  : this(name, description, "") {
-    //}
-
-    ///// <summary>
-    ///// Initializes a new instance of <see cref="PluginDescriptionAttribute"/>.
-    ///// <param name="name">Name of the plugin</param>
-    ///// <param name="description">Description of the plugin</param>
-    ///// <param name="version">Version string of the plugin</param>
-    ///// </summary>
-    //public PluginDescriptionAttribute(string name, string description, string version) {
-    //  this.name = name;
-    //  this.version = version;
-    //  this.description = description;
-    //}
-  }
-}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs	(revision 2481)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/ApplicationBase.cs	(revision 2488)
@@ -29,5 +29,5 @@
   /// Default implementation for the IApplication interface.
   /// </summary>
-  internal abstract class ApplicationBase : IApplication {
+  public abstract class ApplicationBase : IApplication {
     /// <summary>
     /// Initializes a new instance of <see cref="ApplicationBase"/>.
@@ -35,14 +35,14 @@
     public ApplicationBase() { }
 
-    private ApplicationDescriptionAttribute ApplicationDescriptionAttribute {
+    private ApplicationAttribute ApplicationAttribute {
       get {
-        object[] appDescAttributes = this.GetType().GetCustomAttributes(typeof(ApplicationDescriptionAttribute), false);
+        object[] appAttributes = this.GetType().GetCustomAttributes(typeof(ApplicationAttribute), false);
 
         // exactly one attribute of the type ClassInfoAttribute must be given
-        if (appDescAttributes.Length != 1) {
-          throw new InvalidPluginException("Found multiple ApplicationDescriptionAttributes on type " + this.GetType());
+        if (appAttributes.Length != 1) {
+          throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + this.GetType());
         }
 
-        return (ApplicationDescriptionAttribute)appDescAttributes[0];
+        return (ApplicationAttribute)appAttributes[0];
       }
     }
@@ -54,5 +54,5 @@
     /// </summary>
     public string Name {
-      get { return ApplicationDescriptionAttribute.Name; }
+      get { return ApplicationAttribute.Name; }
     }
 
@@ -62,11 +62,5 @@
     public Version Version {
       get {
-        var appDescAttribute = ApplicationDescriptionAttribute;
-        // if the version is not explicitly set in the attribute then the version of the assembly is used as default
-        if (string.IsNullOrEmpty(appDescAttribute.Version)) {
-          return this.GetType().Assembly.GetName().Version;
-        } else {
-          return new Version(appDescAttribute.Version);
-        }
+        return this.GetType().Assembly.GetName().Version;
       }
     }
@@ -77,5 +71,5 @@
     public string Description {
       get {
-        var appDescAttribute = ApplicationDescriptionAttribute;
+        var appDescAttribute = ApplicationAttribute;
         // if the description is not explicitly set in the attribute then the name of the application is used as default
         if (string.IsNullOrEmpty(appDescAttribute.Description)) {
@@ -92,5 +86,5 @@
     public bool RestartOnErrors {
       get {
-        return ApplicationDescriptionAttribute.RestartOnErrors;
+        return ApplicationAttribute.RestartOnErrors;
       }
     }
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs	(revision 2481)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/BaseClasses/PluginBase.cs	(revision 2488)
@@ -37,12 +37,12 @@
     public PluginBase() { }
 
-    private PluginDescriptionAttribute PluginDescriptionAttribute {
+    private PluginAttribute PluginAttribute {
       get {
-        object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginDescriptionAttribute), false);
+        object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginAttribute), false);
         // exactly one attribute of the type PluginDescriptionAttribute must be given
         if (pluginAttributes.Length != 1) {
-          throw new InvalidPluginException("Found multiple PluginDescriptionAttributes on type " + this.GetType());
+          throw new InvalidPluginException("Found multiple PluginAttributes on type " + this.GetType());
         }
-        return (PluginDescriptionAttribute)pluginAttributes[0];
+        return (PluginAttribute)pluginAttributes[0];
       }
     }
@@ -52,5 +52,5 @@
     public string Name {
       get {
-        return PluginDescriptionAttribute.Name;
+        return PluginAttribute.Name;
       }
     }
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/ControlManager.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/ControlManager.cs	(revision 2481)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/ControlManager.cs	(revision 2488)
@@ -38,5 +38,9 @@
     public static IControlManager Manager {
       get { return controlManager; }
-      set { controlManager = value; }
+    }
+
+    public static void RegisterManager(IControlManager manager) {
+      if (controlManager != null) throw new InvalidOperationException("An control manager has already been set.");
+      controlManager = manager;
     }
   }
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/DiscoveryService.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/DiscoveryService.cs	(revision 2481)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/DiscoveryService.cs	(revision 2488)
@@ -24,4 +24,5 @@
 using System.Text;
 using System.Reflection;
+using System.Linq;
 
 namespace HeuristicLab.PluginInfrastructure {
@@ -30,43 +31,30 @@
   /// </summary>
   public class DiscoveryService {
+    //internal static IEnumerable<IPluginDescription> plugins;
 
-    //public PluginDescription[] Plugins {
+    //public IEnumerable<IPluginDescription> Plugins {
     //  get {
-    //    PluginInfo[] plugins = new PluginInfo[PluginManager.Manager.LoadedPlugins.Count];
-    //    PluginManager.Manager.LoadedPlugins.CopyTo(plugins, 0);
-    //    return plugins;
+    //    return DiscoveryService.plugins;
     //  }
     //}
 
     /// <summary>
-    /// Finds all types that are subtypes or equal to the specified type.
+    /// Creates an instance of all types that are subtypes or the same type of the specified type and declared in <paramref name="plugin"/>
     /// </summary>
-    /// <param name="type">Most general type for which to find matching types.</param>
-    /// <returns>The found types as array.</returns>
-    public Type[] GetTypes(Type type) {
-      Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
-      List<Type> types = new List<Type>();
-      foreach (Assembly asm in assemblies) {
-        Array.ForEach<Type>(GetTypes(type, asm), delegate(Type t) {
-          types.Add(t);
-        });
-      }
-      return types.ToArray();
+    /// <typeparam name="T">Most general type.</typeparam>
+    /// <returns>Enumerable of the created instances.</returns>
+    public IEnumerable<T> GetInstances<T>(IPluginDescription plugin) where T : class {
+      return from t in GetTypes(typeof(T), plugin)
+             where !t.IsAbstract && !t.IsInterface && !t.HasElementType
+             select (T)Activator.CreateInstance(t);
     }
-
     /// <summary>
     /// Creates an instance of all types that are subtypes or the same type of the specified type
     /// </summary>
     /// <typeparam name="T">Most general type.</typeparam>
-    /// <returns>The created instances as array.</returns>
-    public T[] GetInstances<T>() where T : class {
-      Type[] types = GetTypes(typeof(T));
-      List<T> instances = new List<T>();
-      foreach (Type t in types) {
-        if (!t.IsAbstract && !t.IsInterface && !t.HasElementType) {
-          instances.Add((T)Activator.CreateInstance(t));
-        }
-      }
-      return instances.ToArray();
+    /// <returns>Enumerable of the created instances.</returns>
+    public IEnumerable<T> GetInstances<T>() where T : class {
+      return from i in GetInstances(typeof(T))
+             select (T)i;
     }
 
@@ -75,36 +63,35 @@
     /// </summary>
     /// <typeparam name="type">Most general type.</typeparam>
-    /// <returns>The created instances as array.</returns>
-    public object[] GetInstances(Type type) {
-      Type[] types = GetTypes(type);
-      List<object> instances = new List<object>();
-      foreach (Type t in types) {
-        if (!t.IsAbstract && !t.IsInterface && !t.HasElementType) {
-          instances.Add(Activator.CreateInstance(t));
-        }
-      }
-      return instances.ToArray();
+    /// <returns>Enumerable of the created instances.</returns>
+    public IEnumerable<object> GetInstances(Type type) {
+      return from t in GetTypes(type)
+             where !t.IsAbstract && !t.IsInterface && !t.HasElementType
+             select Activator.CreateInstance(t);
     }
 
-    ///// <summary>
-    ///// Finds all types that are subtypes or equal to the specified type if they are part of the given
-    ///// <paramref name="plugin"/>.
-    ///// </summary>
-    ///// <param name="type">Most general type for which to find matching types.</param>
-    ///// <param name="plugin">The plugin the subtypes must be part of.</param>
-    ///// <returns>The found types as array.</returns>
-    //public Type[] GetTypes(Type type, PluginInfo plugin) {
-    //  Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
-    //  List<Type> types = new List<Type>();
-    //  foreach (Assembly asm in assemblies) {
-    //    if (plugin.Assemblies.Contains(asm.Location)) {
-    //      Array.ForEach<Type>(GetTypes(type, asm), delegate(Type t) {
-    //        types.Add(t);
-    //      });
-    //    }
-    //  }
+    /// <summary>
+    /// Finds all types that are subtypes or equal to the specified type.
+    /// </summary>
+    /// <param name="type">Most general type for which to find matching types.</param>
+    /// <returns>Enumerable of the discovered types.</returns>
+    public IEnumerable<Type> GetTypes(Type type) {
+      return from asm in AppDomain.CurrentDomain.GetAssemblies()
+             from t in GetTypes(type, asm)
+             select t;
+    }
 
-    //  return types.ToArray();
-    //}
+    /// <summary>
+    /// Finds all types that are subtypes or equal to the specified type if they are part of the given
+    /// <paramref name="plugin"/>.
+    /// </summary>
+    /// <param name="type">Most general type for which to find matching types.</param>
+    /// <param name="plugin">The plugin the subtypes must be part of.</param>
+    /// <returns>Enumerable of the discovered types.</returns>
+    public IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription) {
+      return from asm in AppDomain.CurrentDomain.GetAssemblies()
+             where pluginDescription.Assemblies.Contains(asm.Location)
+             from t in GetTypes(type, asm)
+             select t;
+    }
 
     ///// <summary>
@@ -130,13 +117,9 @@
     /// <param name="type">Most general type we want to find.</param>
     /// <param name="assembly">Assembly that should be searched for types.</param>
-    /// <returns>The found types as array.</returns>
-    internal Type[] GetTypes(Type type, Assembly assembly) {
-      List<Type> types = new List<Type>();
-      foreach (Type t in assembly.GetTypes()) {
-        if (type.IsAssignableFrom(t)) {
-          types.Add(t);
-        }
-      }
-      return types.ToArray();
+    /// <returns>Enumerable of the discovered types.</returns>
+    private IEnumerable<Type> GetTypes(Type type, Assembly assembly) {
+      return from t in assembly.GetTypes()
+             where type.IsAssignableFrom(t)
+             select t;
     }
 
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj	(revision 2481)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj	(revision 2488)
@@ -86,18 +86,23 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Attributes\ApplicationDescriptionAttribute.cs" />
+    <Compile Include="Attributes\ApplicationAttribute.cs" />
     <Compile Include="Attributes\AssemblyBuildDateAttribute.cs" />
+    <Compile Include="Attributes\PluginAttribute.cs" />
     <Compile Include="Attributes\PluginDependencyAttribute.cs" />
-    <Compile Include="Attributes\PluginDescriptionAttribute.cs" />
     <Compile Include="Attributes\PluginFileAttribute.cs" />
     <Compile Include="BaseClasses\ApplicationBase.cs" />
     <Compile Include="BaseClasses\PluginBase.cs" />
+    <Compile Include="Interfaces\IApplicationManager.cs" />
+    <Compile Include="Interfaces\IApplicationDescription.cs" />
     <Compile Include="Interfaces\IApplication.cs" />
     <Compile Include="Interfaces\IControl.cs" />
     <Compile Include="Interfaces\IControlManager.cs" />
     <Compile Include="Interfaces\IPlugin.cs" />
-    <Compile Include="DiscoveryService.cs" />
     <Compile Include="ControlManager.cs" />
+    <Compile Include="Interfaces\IPluginDescription.cs" />
     <Compile Include="InvalidPluginException.cs" />
+    <Compile Include="PluginDescriptionIterator.cs" />
+    <Compile Include="ApplicationManager.cs" />
+    <Compile Include="PluginState.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <EmbeddedResource Include="Properties\Resources.resx">
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationDescription.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationDescription.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationDescription.cs	(revision 2488)
@@ -0,0 +1,32 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+
+namespace HeuristicLab.PluginInfrastructure {
+  public interface IApplicationDescription {
+    string Name { get; }
+    Version Version { get; }
+    string DeclaringAssemblyName { get; }
+    string DeclaringTypeName { get; }
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationManager.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationManager.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IApplicationManager.cs	(revision 2488)
@@ -0,0 +1,44 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using System.Reflection;
+
+namespace HeuristicLab.PluginInfrastructure {
+  /// <summary>
+  /// Interface for application managers.
+  /// </summary>
+  public interface IApplicationManager {
+    IEnumerable<IPluginDescription> Plugins { get; }
+    IEnumerable<IApplicationDescription> Applications { get; }
+
+    IEnumerable<T> GetInstances<T>(IPluginDescription plugin) where T : class;
+    IEnumerable<T> GetInstances<T>() where T : class;
+    IEnumerable<object> GetInstances(Type type);
+
+    IEnumerable<Type> GetTypes(Type type);
+    IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription);
+    // IEnumerable<Type> GetTypes(Type type, Assembly assembly);
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IPluginDescription.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IPluginDescription.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Interfaces/IPluginDescription.cs	(revision 2488)
@@ -0,0 +1,39 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+
+namespace HeuristicLab.PluginInfrastructure {
+  public interface IPluginDescription {
+    string Name { get; }
+    Version Version { get; }
+    DateTime BuildDate { get; }
+    PluginState PluginState { get; }
+    IEnumerable<string> Files { get; }
+    IEnumerable<IPluginDescription> Dependencies { get; }
+    IEnumerable<string> Assemblies { get; }
+    void Enable();
+    void Disable();
+    void Load();
+    void Unload();
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/PluginDescriptionIterator.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/PluginDescriptionIterator.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/PluginDescriptionIterator.cs	(revision 2488)
@@ -0,0 +1,45 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HeuristicLab.PluginInfrastructure {
+  public static class PluginDescriptionIterator {
+    public static IEnumerable<IPluginDescription> IterateInDependencyOrder(IEnumerable<IPluginDescription> pluginDescriptions) {
+      // list to make sure we yield each description only once
+      List<IPluginDescription> yieldedDescriptions = new List<IPluginDescription>();
+      foreach (var desc in pluginDescriptions) {
+        foreach (var dependency in IterateInDependencyOrder(desc.Dependencies)) {
+          if (!yieldedDescriptions.Contains(dependency)) {
+            yieldedDescriptions.Add(dependency);
+            yield return dependency;
+          }
+        }
+        if (!yieldedDescriptions.Contains(desc)) {
+          yieldedDescriptions.Add(desc);
+          yield return desc;
+        }
+      }
+    }
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/PluginState.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/PluginState.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/PluginState.cs	(revision 2488)
@@ -0,0 +1,31 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HeuristicLab.PluginInfrastructure {
+  [Serializable]
+  public enum PluginState {
+    Undefined, Enabled, Disabled, Loaded
+  }
+}
