Index: /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs	(revision 7845)
+++ /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs	(revision 7846)
@@ -46,10 +46,4 @@
     private void InitializeComponent() {
       this.components = new System.ComponentModel.Container();
-      System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("QAPLIB", System.Windows.Forms.HorizontalAlignment.Left);
-      System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("TSPLIB", System.Windows.Forms.HorizontalAlignment.Left);
-      System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("bur26a");
-      System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("esc32a");
-      System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("berlin52");
-      System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("ch130");
       this.okButton = new System.Windows.Forms.Button();
       this.cancelButton = new System.Windows.Forms.Button();
@@ -62,4 +56,9 @@
       this.instancesListView = new System.Windows.Forms.ListView();
       this.columnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+      this.experimentCreationBackgroundWorker = new System.ComponentModel.BackgroundWorker();
+      this.experimentCreationProgressBar = new System.Windows.Forms.ProgressBar();
+      this.progressLabel = new System.Windows.Forms.Label();
+      this.selectAllCheckBox = new System.Windows.Forms.CheckBox();
+      this.selectNoneCheckBox = new System.Windows.Forms.CheckBox();
       ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
       this.SuspendLayout();
@@ -164,38 +163,69 @@
       this.instancesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
             this.columnHeader});
-      listViewGroup1.Header = "QAPLIB";
-      listViewGroup1.Name = "QAPLIBHeader";
-      listViewGroup2.Header = "TSPLIB";
-      listViewGroup2.Name = "TSPLIBHeader";
-      listViewGroup2.Tag = "";
-      this.instancesListView.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] {
-            listViewGroup1,
-            listViewGroup2});
       this.instancesListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
-      listViewItem1.Checked = true;
-      listViewItem1.Group = listViewGroup1;
-      listViewItem1.StateImageIndex = 1;
-      listViewItem2.Checked = true;
-      listViewItem2.Group = listViewGroup1;
-      listViewItem2.StateImageIndex = 1;
-      listViewItem3.Group = listViewGroup2;
-      listViewItem3.StateImageIndex = 0;
-      listViewItem4.Group = listViewGroup2;
-      listViewItem4.StateImageIndex = 0;
-      this.instancesListView.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
-            listViewItem1,
-            listViewItem2,
-            listViewItem3,
-            listViewItem4});
-      this.instancesListView.Location = new System.Drawing.Point(113, 54);
+      this.instancesListView.Location = new System.Drawing.Point(113, 77);
       this.instancesListView.Name = "instancesListView";
-      this.instancesListView.Size = new System.Drawing.Size(156, 199);
+      this.instancesListView.Size = new System.Drawing.Size(156, 176);
       this.instancesListView.TabIndex = 6;
       this.instancesListView.UseCompatibleStateImageBehavior = false;
       this.instancesListView.View = System.Windows.Forms.View.Details;
+      this.instancesListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.instancesListView_ItemChecked);
       // 
       // columnHeader
       // 
       this.columnHeader.Width = 150;
+      // 
+      // experimentCreationBackgroundWorker
+      // 
+      this.experimentCreationBackgroundWorker.WorkerReportsProgress = true;
+      this.experimentCreationBackgroundWorker.WorkerSupportsCancellation = true;
+      this.experimentCreationBackgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.experimentCreationBackgroundWorker_DoWork);
+      this.experimentCreationBackgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.experimentCreationBackgroundWorker_ProgressChanged);
+      this.experimentCreationBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.experimentCreationBackgroundWorker_RunWorkerCompleted);
+      // 
+      // experimentCreationProgressBar
+      // 
+      this.experimentCreationProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.experimentCreationProgressBar.Location = new System.Drawing.Point(15, 259);
+      this.experimentCreationProgressBar.Name = "experimentCreationProgressBar";
+      this.experimentCreationProgressBar.Size = new System.Drawing.Size(92, 23);
+      this.experimentCreationProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
+      this.experimentCreationProgressBar.TabIndex = 7;
+      this.experimentCreationProgressBar.Visible = false;
+      // 
+      // progressLabel
+      // 
+      this.progressLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+      this.progressLabel.BackColor = System.Drawing.SystemColors.Control;
+      this.progressLabel.Location = new System.Drawing.Point(113, 259);
+      this.progressLabel.Name = "progressLabel";
+      this.progressLabel.Size = new System.Drawing.Size(75, 23);
+      this.progressLabel.TabIndex = 8;
+      this.progressLabel.Text = "label1";
+      this.progressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+      this.progressLabel.Visible = false;
+      // 
+      // selectAllCheckBox
+      // 
+      this.selectAllCheckBox.AutoSize = true;
+      this.selectAllCheckBox.Location = new System.Drawing.Point(113, 54);
+      this.selectAllCheckBox.Name = "selectAllCheckBox";
+      this.selectAllCheckBox.Size = new System.Drawing.Size(67, 17);
+      this.selectAllCheckBox.TabIndex = 9;
+      this.selectAllCheckBox.Text = "select all";
+      this.selectAllCheckBox.UseVisualStyleBackColor = true;
+      this.selectAllCheckBox.CheckedChanged += new System.EventHandler(this.selectAllCheckBox_CheckedChanged);
+      // 
+      // selectNoneCheckBox
+      // 
+      this.selectNoneCheckBox.AutoSize = true;
+      this.selectNoneCheckBox.Location = new System.Drawing.Point(186, 54);
+      this.selectNoneCheckBox.Name = "selectNoneCheckBox";
+      this.selectNoneCheckBox.Size = new System.Drawing.Size(81, 17);
+      this.selectNoneCheckBox.TabIndex = 9;
+      this.selectNoneCheckBox.Text = "select none";
+      this.selectNoneCheckBox.UseVisualStyleBackColor = true;
+      this.selectNoneCheckBox.CheckedChanged += new System.EventHandler(this.selectNoneCheckBox_CheckedChanged);
       // 
       // CreateExperimentDialog
@@ -206,4 +236,6 @@
       this.CancelButton = this.cancelButton;
       this.ClientSize = new System.Drawing.Size(281, 294);
+      this.Controls.Add(this.selectNoneCheckBox);
+      this.Controls.Add(this.selectAllCheckBox);
       this.Controls.Add(this.instancesListView);
       this.Controls.Add(this.repetitionsNumericUpDown);
@@ -214,4 +246,6 @@
       this.Controls.Add(this.cancelButton);
       this.Controls.Add(this.okButton);
+      this.Controls.Add(this.progressLabel);
+      this.Controls.Add(this.experimentCreationProgressBar);
       this.MaximizeBox = false;
       this.MinimizeBox = false;
@@ -221,4 +255,6 @@
       this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
       this.Text = "Create Experiment";
+      this.TopMost = true;
+      this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CreateExperimentDialog_FormClosing);
       ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
       this.ResumeLayout(false);
@@ -239,4 +275,9 @@
     private System.Windows.Forms.ListView instancesListView;
     private System.Windows.Forms.ColumnHeader columnHeader;
+    private System.ComponentModel.BackgroundWorker experimentCreationBackgroundWorker;
+    private System.Windows.Forms.ProgressBar experimentCreationProgressBar;
+    private System.Windows.Forms.Label progressLabel;
+    private System.Windows.Forms.CheckBox selectAllCheckBox;
+    private System.Windows.Forms.CheckBox selectNoneCheckBox;
 
   }
Index: /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs
===================================================================
--- /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs	(revision 7845)
+++ /trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs	(revision 7846)
@@ -22,8 +22,9 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
+using System.Threading;
 using System.Windows.Forms;
 using HeuristicLab.Optimization;
-using HeuristicLab.PluginInfrastructure;
 using HeuristicLab.Problems.Instances;
 
@@ -37,4 +38,5 @@
         experiment = null;
         okButton.Enabled = optimizer != null;
+        FillOrHideInstanceListView();
       }
     }
@@ -45,37 +47,37 @@
     }
 
+    private bool createBatchRun;
+    private int repetitions;
+    private EventWaitHandle backgroundWorkerWaitHandle = new ManualResetEvent(false);
+    private bool suppressListViewEventHandling;
+
     public CreateExperimentDialog() : this(null) { }
     public CreateExperimentDialog(IOptimizer optimizer) {
       InitializeComponent();
+      createBatchRun = createBatchRunCheckBox.Checked;
+      repetitions = (int)repetitionsNumericUpDown.Value;
       Optimizer = optimizer;
-      experiment = null;
-      instancesListView.Items.Clear();
-      instancesListView.Groups.Clear();
-      FillOrHideInstanceListView();
     }
 
     private void FillOrHideInstanceListView() {
-      if (Optimizer != null && optimizer is IAlgorithm) {
+      if (optimizer != null && optimizer is IAlgorithm) {
         var algorithm = (IAlgorithm)Optimizer;
         if (algorithm.Problem != null) {
-          var instanceProviders = GetProblemInstanceProviders(algorithm.Problem);
+          var instanceProviders = ProblemInstanceManager.GetProviders(algorithm.Problem);
           if (instanceProviders.Any()) {
-            foreach (var provider in instanceProviders) {
-              var group = new ListViewGroup(provider.Name, provider.Name);
-              group.Tag = provider;
-              instancesListView.Groups.Add(group);
-              IEnumerable<IDataDescriptor> descriptors = ((dynamic)provider).GetDataDescriptors();
-              foreach (var d in descriptors) {
-                var item = new ListViewItem(d.Name, group);
-                item.Checked = true;
-                item.Tag = d;
-                instancesListView.Items.Add(item);
-              }
+            FillInstanceListView(instanceProviders);
+            if (instancesListView.Items.Count > 0) {
+              selectAllCheckBox.Visible = true;
+              selectNoneCheckBox.Visible = true;
+              instancesLabel.Visible = true;
+              instancesListView.Visible = true;
+              Height = 330;
+              return;
             }
-            instancesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
-            if (instancesListView.Items.Count > 0) return;
           }
         }
       }
+      selectAllCheckBox.Visible = false;
+      selectNoneCheckBox.Visible = false;
       instancesLabel.Visible = false;
       instancesListView.Visible = false;
@@ -83,48 +85,116 @@
     }
 
-    private IEnumerable<IProblemInstanceProvider> GetProblemInstanceProviders(IProblem problem) {
-      var consumerTypes = problem.GetType().GetInterfaces()
-        .Where(x => x.IsGenericType
-          && x.GetGenericTypeDefinition() == typeof(IProblemInstanceConsumer<>));
-
-      if (consumerTypes.Any()) {
-        var instanceTypes = consumerTypes
-          .Select(x => x.GetGenericArguments().First())
-          .Select(x => typeof(IProblemInstanceProvider<>).MakeGenericType(x));
-
-        foreach (var type in instanceTypes) {
-          foreach (var provider in ApplicationManager.Manager.GetInstances(type))
-            yield return (IProblemInstanceProvider)provider;
+    private void FillInstanceListView(IEnumerable<IProblemInstanceProvider> instanceProviders) {
+      foreach (var provider in instanceProviders) {
+        var group = new ListViewGroup(provider.Name, provider.Name);
+        group.Tag = provider;
+        instancesListView.Groups.Add(group);
+        foreach (var d in ProblemInstanceManager.GetDataDescriptors(provider)) {
+          var item = new ListViewItem(d.Name, group);
+          item.Tag = d;
+          instancesListView.Items.Add(item);
         }
       }
+      instancesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
+      selectAllCheckBox.Checked = true;
     }
 
     private void createBatchRunCheckBox_CheckedChanged(object sender, EventArgs e) {
       repetitionsNumericUpDown.Enabled = createBatchRunCheckBox.Checked;
+      createBatchRun = createBatchRunCheckBox.Checked;
     }
     private void repetitionsNumericUpDown_Validated(object sender, EventArgs e) {
       if (repetitionsNumericUpDown.Text == string.Empty)
         repetitionsNumericUpDown.Text = repetitionsNumericUpDown.Value.ToString();
+      repetitions = (int)repetitionsNumericUpDown.Value;
+    }
+    private void selectAllCheckBox_CheckedChanged(object sender, EventArgs e) {
+      if (selectAllCheckBox.Checked) {
+        selectNoneCheckBox.Checked = false;
+        if (instancesListView.CheckedItems.Count == instancesListView.Items.Count) return;
+        try {
+          suppressListViewEventHandling = true;
+          foreach (var item in instancesListView.Items.OfType<ListViewItem>()) {
+            item.Checked = true;
+          }
+        } finally { suppressListViewEventHandling = false; }
+      }
+    }
+    private void selectNoneCheckBox_CheckedChanged(object sender, EventArgs e) {
+      if (selectNoneCheckBox.Checked) {
+        selectAllCheckBox.Checked = false;
+        if (instancesListView.CheckedItems.Count == 0) return;
+        try {
+          suppressListViewEventHandling = true;
+          foreach (var item in instancesListView.Items.OfType<ListViewItem>()) {
+            item.Checked = false;
+          }
+        } finally { suppressListViewEventHandling = false; }
+      }
+    }
+    private void instancesListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
+      if (!suppressListViewEventHandling) {
+        selectAllCheckBox.Checked = instancesListView.Items.Count == instancesListView.CheckedItems.Count;
+        selectNoneCheckBox.Checked = instancesListView.CheckedItems.Count == 0;
+      }
     }
     private void okButton_Click(object sender, EventArgs e) {
-      experiment = new Experiment();
-      if (instancesListView.CheckedItems.Count == 0) {
-        AddOptimizer((IOptimizer)Optimizer.Clone());
+      SetMode(createExperiment: true);
+      experimentCreationBackgroundWorker.RunWorkerAsync(GetSelectedInstances());
+      backgroundWorkerWaitHandle.WaitOne();
+    }
+    private void experimentCreationBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
+      backgroundWorkerWaitHandle.Set();
+      experimentCreationBackgroundWorker.ReportProgress(0, string.Empty);
+      var items = (Dictionary<IProblemInstanceProvider, List<IDataDescriptor>>)e.Argument;
+      var localExperiment = new Experiment();
+      if (items.Count == 0) {
+        AddOptimizer((IOptimizer)Optimizer.Clone(), localExperiment);
+        experimentCreationBackgroundWorker.ReportProgress(100, string.Empty);
       } else {
-        foreach (var item in instancesListView.CheckedItems.OfType<ListViewItem>()) {
-          var descriptor = (IDataDescriptor)item.Tag;
-          var provider = (IProblemInstanceProvider)item.Group.Tag;
-          var algorithm = (IAlgorithm)Optimizer.Clone();
-          ((dynamic)algorithm.Problem).Load(((dynamic)provider).LoadData(descriptor));
-          AddOptimizer(algorithm);
+        int counter = 0, total = items.SelectMany(x => x.Value).Count();
+        foreach (var provider in items.Keys) {
+          foreach (var descriptor in items[provider]) {
+            var algorithm = (IAlgorithm)Optimizer.Clone();
+            ProblemInstanceManager.LoadData(provider, descriptor, (IProblemInstanceConsumer)algorithm.Problem);
+            AddOptimizer(algorithm, localExperiment);
+            counter++;
+            experimentCreationBackgroundWorker.ReportProgress((int)Math.Round(100.0 * counter / total), descriptor.Name);
+            if (experimentCreationBackgroundWorker.CancellationPending) {
+              e.Cancel = true;
+              localExperiment = null;
+              break;
+            }
+          }
         }
       }
-      Experiment.Prepare(true);
-    }
-
-    private void AddOptimizer(IOptimizer optimizer) {
-      if (createBatchRunCheckBox.Checked) {
+      if (localExperiment != null) localExperiment.Prepare(true);
+      e.Result = localExperiment;
+    }
+    private void experimentCreationBackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) {
+      experimentCreationProgressBar.Value = e.ProgressPercentage;
+      progressLabel.Text = (string)e.UserState;
+    }
+    private void experimentCreationBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
+      SetMode(createExperiment: false);
+      if (e.Error != null) MessageBox.Show(e.Error.Message, "Error occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
+      if (!e.Cancelled && e.Error == null) {
+        experiment = (Experiment)e.Result;
+        DialogResult = System.Windows.Forms.DialogResult.OK;
+        Close();
+      }
+    }
+    private void CreateExperimentDialog_FormClosing(object sender, FormClosingEventArgs e) {
+      if (experimentCreationBackgroundWorker.IsBusy) {
+        if (DialogResult != System.Windows.Forms.DialogResult.OK)
+          experimentCreationBackgroundWorker.CancelAsync();
+        e.Cancel = true;
+      }
+    }
+
+    private void AddOptimizer(IOptimizer optimizer, Experiment experiment) {
+      if (createBatchRun) {
         var batchRun = new BatchRun();
-        batchRun.Repetitions = (int)repetitionsNumericUpDown.Value;
+        batchRun.Repetitions = repetitions;
         batchRun.Optimizer = optimizer;
         experiment.Optimizers.Add(batchRun);
@@ -133,4 +203,26 @@
       }
     }
+
+    private void SetMode(bool createExperiment) {
+      createBatchRunCheckBox.Enabled = !createExperiment;
+      repetitionsNumericUpDown.Enabled = !createExperiment;
+      selectAllCheckBox.Enabled = !createExperiment;
+      selectNoneCheckBox.Enabled = !createExperiment;
+      instancesListView.Enabled = !createExperiment;
+      okButton.Enabled = !createExperiment;
+      okButton.Visible = !createExperiment;
+      progressLabel.Visible = createExperiment;
+      experimentCreationProgressBar.Visible = createExperiment;
+    }
+
+    private Dictionary<IProblemInstanceProvider, List<IDataDescriptor>> GetSelectedInstances() {
+      var selectedInstances = new Dictionary<IProblemInstanceProvider, List<IDataDescriptor>>();
+      foreach (var checkedItem in instancesListView.CheckedItems.OfType<ListViewItem>()) {
+        if (!selectedInstances.ContainsKey((IProblemInstanceProvider)checkedItem.Group.Tag))
+          selectedInstances.Add((IProblemInstanceProvider)checkedItem.Group.Tag, new List<IDataDescriptor>());
+        selectedInstances[(IProblemInstanceProvider)checkedItem.Group.Tag].Add((IDataDescriptor)checkedItem.Tag);
+      }
+      return selectedInstances;
+    }
   }
 }
Index: /trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceConsumerView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceConsumerView.cs	(revision 7845)
+++ /trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceConsumerView.cs	(revision 7846)
@@ -28,5 +28,4 @@
 using HeuristicLab.MainForm;
 using HeuristicLab.MainForm.WindowsForms;
-using HeuristicLab.PluginInfrastructure;
 
 namespace HeuristicLab.Problems.Instances.Views {
@@ -63,25 +62,8 @@
       } else {
         problemInstanceProviderComboBox.DisplayMember = "Name";
-        ProblemInstanceProviders = GetProblemInstanceProviders();
+        ProblemInstanceProviders = ProblemInstanceManager.GetProviders(Content);
         problemInstanceProviderComboBox.DataSource = ProblemInstanceProviders.OrderBy(x => x.Name).ToList();
       }
       SetEnabledStateOfControls();
-    }
-
-    private IEnumerable<IProblemInstanceProvider> GetProblemInstanceProviders() {
-      var consumerTypes = Content.GetType().GetInterfaces()
-        .Where(x => x.IsGenericType
-          && x.GetGenericTypeDefinition() == typeof(IProblemInstanceConsumer<>));
-
-      if (consumerTypes.Any()) {
-        var instanceTypes = consumerTypes
-          .Select(x => x.GetGenericArguments().First())
-          .Select(x => typeof(IProblemInstanceProvider<>).MakeGenericType(x));
-
-        foreach (var type in instanceTypes) {
-          foreach (var provider in ApplicationManager.Manager.GetInstances(type))
-            yield return (IProblemInstanceProvider)provider;
-        }
-      }
     }
 
Index: /trunk/sources/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj	(revision 7845)
+++ /trunk/sources/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj	(revision 7846)
@@ -105,4 +105,5 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.CSharp" />
     <Reference Include="System" />
     <Reference Include="System.Core" />
@@ -111,4 +112,5 @@
   <ItemGroup>
     <None Include="Plugin.cs.frame" />
+    <Compile Include="ProblemInstanceManager.cs" />
     <Compile Include="IProblemInstanceExporter.cs" />
     <Compile Include="TableFileParser.cs" />
Index: /trunk/sources/HeuristicLab.Problems.Instances/3.3/ProblemInstanceManager.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.Instances/3.3/ProblemInstanceManager.cs	(revision 7846)
+++ /trunk/sources/HeuristicLab.Problems.Instances/3.3/ProblemInstanceManager.cs	(revision 7846)
@@ -0,0 +1,54 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using System.Linq;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Problems.Instances {
+  public class ProblemInstanceManager {
+    public static IEnumerable<IProblemInstanceProvider> GetProviders(object item) {
+      var consumerTypes = item.GetType().GetInterfaces()
+        .Where(x => x.IsGenericType
+          && x.GetGenericTypeDefinition() == typeof(IProblemInstanceConsumer<>));
+
+      if (consumerTypes.Any()) {
+        var instanceTypes = consumerTypes
+          .Select(x => x.GetGenericArguments().First())
+          .Select(x => typeof(IProblemInstanceProvider<>).MakeGenericType(x));
+
+        foreach (var type in instanceTypes) {
+          foreach (var provider in ApplicationManager.Manager.GetInstances(type))
+            yield return (IProblemInstanceProvider)provider;
+        }
+      }
+    }
+
+    public static IEnumerable<IDataDescriptor> GetDataDescriptors(IProblemInstanceProvider provider) {
+      IEnumerable<IDataDescriptor> descriptors = ((dynamic)provider).GetDataDescriptors();
+      return descriptors;
+    }
+
+    public static void LoadData(IProblemInstanceProvider provider, IDataDescriptor descriptor, IProblemInstanceConsumer consumer) {
+      ((dynamic)consumer).Load(((dynamic)provider).LoadData(descriptor));
+    }
+  }
+}
