Index: /branches/ParameterBinding/HeuristicLab.Core/3.3/ItemBinding.cs
===================================================================
--- /branches/ParameterBinding/HeuristicLab.Core/3.3/ItemBinding.cs	(revision 4789)
+++ /branches/ParameterBinding/HeuristicLab.Core/3.3/ItemBinding.cs	(revision 4790)
@@ -7,4 +7,6 @@
 using System.Reflection;
 using System.Reflection.Emit;
+using System.ComponentModel;
+using System.Linq.Expressions;
 
 namespace HeuristicLab.Core {
@@ -22,5 +24,8 @@
     [Storable]
     private bool bound;
-
+    [Storable]
+    private LambdaExpression bindingExpression;
+
+    private Delegate bindingFunc;
     private static object evhCacheLock = new object();
     private static Dictionary<Type, DynamicMethod> eventHandlerCache = new Dictionary<Type, DynamicMethod>();
@@ -33,4 +38,7 @@
       this.source = cloner.Clone(original.source);
       this.sourcePath = original.sourcePath;
+      this.bindingExpression = original.bindingExpression;
+      if (this.bindingExpression != null)
+        this.bindingFunc = this.bindingExpression.Compile();
       if (original.bound) Bind();
     }
@@ -42,4 +50,9 @@
       this.bound = false;
     }
+    public ItemBinding(IDeepCloneable target, string targetPath, IDeepCloneable source, string sourcePath, LambdaExpression func)
+      : this(target, targetPath, source, sourcePath) {
+      this.bindingExpression = func;
+      this.bindingFunc = this.bindingExpression.Compile();
+    }
 
     public IDeepCloneable Clone(Cloner cloner) {
@@ -54,4 +67,6 @@
     private void AfterDeserialization() {
       if (bound) RegisterEventHandlers();
+      if (bindingExpression != null)
+        bindingFunc = bindingExpression.Compile();
     }
 
@@ -71,5 +86,5 @@
       object current = source;
       foreach (string property in properties) {
-        TryHookToChangedEvent(current, property + "Changed");
+        TryHookToChangedEvent(current, property);
         MethodInfo mInfo = current.GetType().GetProperty(property, Flags).GetGetMethod(true);
         object next = mInfo.Invoke(current, null);
@@ -83,5 +98,5 @@
       object current = source;
       foreach (string property in properties) {
-        TryUnhookFromChangedEvent(current, property + "Changed");
+        TryUnhookFromChangedEvent(current, property);
         MethodInfo mInfo = current.GetType().GetProperty(property, Flags).GetGetMethod(true);
         object next = mInfo.Invoke(current, null);
@@ -95,12 +110,14 @@
       string[] sourceProperties = sourcePath.Split('.');
       object cSource = source;
-      #region Navigate to source property
+      #region Navigate to source property (readd bindings if necessary)
       bool reregister = false;
       for (int i = 0; i < sourceProperties.Length; i++) {
         if (cSource == null) return;
         string property = sourceProperties[i];
-        if (reregister) TryHookToChangedEvent(cSource, property + "Changed");
+        if (reregister) TryHookToChangedEvent(cSource, property);
         if (cSource == sender) reregister = true;
-        object next = cSource.GetType().GetProperty(property, Flags).GetGetMethod(true).Invoke(cSource, null);
+        PropertyInfo pInfo = cSource.GetType().GetProperty(property, Flags);
+        if (pInfo == null) return;
+        object next = pInfo.GetGetMethod(true).Invoke(cSource, null);
         cSource = next;
       }
@@ -112,5 +129,7 @@
       #region Navigate to target property
       for (int i = 0; i < targetProperties.Length - 1; i++) {
-        cTarget = cTarget.GetType().GetProperty(targetProperties[i], Flags).GetGetMethod(true).Invoke(cTarget, null);
+        PropertyInfo pInfo = cTarget.GetType().GetProperty(targetProperties[i], Flags);
+        if (pInfo == null) return;
+        cTarget = pInfo.GetGetMethod(true).Invoke(cTarget, null);
         if (cTarget == null) return;
       }
@@ -119,5 +138,7 @@
       #endregion
 
-      if (cSource == null && !targetSetter.GetParameters().First().ParameterType.IsValueType
+      if (bindingFunc != null) {
+        targetSetter.Invoke(cTarget, new object[] { bindingFunc.DynamicInvoke(new object[] { cSource }) });
+      } else if (cSource == null && !targetSetter.GetParameters().First().ParameterType.IsValueType
         || cSource != null && cSource.GetType().IsValueType)
         targetSetter.Invoke(cTarget, new object[] { cSource });
@@ -128,22 +149,38 @@
 
     private bool TryHookToChangedEvent(object obj, string property) {
-      EventInfo eInfo = obj.GetType().GetEvent(property, Flags);
-      if (eInfo != null) {
-        Type[] methodParams = eInfo.EventHandlerType.GetMethod("Invoke").GetParameters().Select(x => x.ParameterType).ToArray();
-        if (!eventHandlerCache.ContainsKey(methodParams[1]))
-          CreateAndAddDynamicEventHandler(eInfo, methodParams);
-        eInfo.AddEventHandler(obj, eventHandlerCache[methodParams[1]].CreateDelegate(eInfo.EventHandlerType, this));
-      }
-      return eInfo != null;
+      INotifyPropertyChanged npc = (obj as INotifyPropertyChanged);
+      if (npc != null) {
+        npc.PropertyChanged += new PropertyChangedEventHandler(source_PropertyChanged);
+        return true;
+      } else {
+        EventInfo eInfo = obj.GetType().GetEvent(property + "Changed", Flags);
+        if (eInfo != null) {
+          Type[] methodParams = eInfo.EventHandlerType.GetMethod("Invoke").GetParameters().Select(x => x.ParameterType).ToArray();
+          if (!eventHandlerCache.ContainsKey(methodParams[1]))
+            CreateAndAddDynamicEventHandler(eInfo, methodParams);
+          eInfo.AddEventHandler(obj, eventHandlerCache[methodParams[1]].CreateDelegate(eInfo.EventHandlerType, this));
+        }
+        return eInfo != null;
+      }
     }
 
     private bool TryUnhookFromChangedEvent(object obj, string property) {
-      EventInfo eInfo = obj.GetType().GetEvent(property, Flags);
-      if (eInfo != null) {
-        Type[] methodParams = eInfo.EventHandlerType.GetMethod("Invoke").GetParameters().Select(x => x.ParameterType).ToArray();
-        if (eventHandlerCache.ContainsKey(methodParams[1]))
-          eInfo.RemoveEventHandler(obj, eventHandlerCache[methodParams[1]].CreateDelegate(eInfo.EventHandlerType, this));
-      }
-      return eInfo != null;
+      INotifyPropertyChanged npc = (obj as INotifyPropertyChanged);
+      if (npc != null) {
+        npc.PropertyChanged -= new PropertyChangedEventHandler(source_PropertyChanged);
+        return true;
+      } else {
+        EventInfo eInfo = obj.GetType().GetEvent(property, Flags);
+        if (eInfo != null) {
+          Type[] methodParams = eInfo.EventHandlerType.GetMethod("Invoke").GetParameters().Select(x => x.ParameterType).ToArray();
+          if (eventHandlerCache.ContainsKey(methodParams[1]))
+            eInfo.RemoveEventHandler(obj, eventHandlerCache[methodParams[1]].CreateDelegate(eInfo.EventHandlerType, this));
+        }
+        return eInfo != null;
+      }
+    }
+
+    private void source_PropertyChanged(object sender, PropertyChangedEventArgs e) {
+      ExecuteBinding(sender);
     }
 
@@ -152,5 +189,5 @@
         if (!eventHandlerCache.ContainsKey(methodParams[1])) {
           Type[] instanceMethodParams = new Type[] { GetType() }.Concat(methodParams).ToArray();
-          DynamicMethod dynamicEventHandler = new DynamicMethod("sourceChanged", null, instanceMethodParams, GetType());
+          DynamicMethod dynamicEventHandler = new DynamicMethod("source_Changed", null, instanceMethodParams, GetType());
           MethodInfo executeBindingMethodInfo = GetType().GetMethod("ExecuteBinding", Flags);
           ILGenerator iLG = dynamicEventHandler.GetILGenerator();
Index: /branches/ParameterBinding/HeuristicLab.Core/3.3/ParameterizedNamedItem.cs
===================================================================
--- /branches/ParameterBinding/HeuristicLab.Core/3.3/ParameterizedNamedItem.cs	(revision 4789)
+++ /branches/ParameterBinding/HeuristicLab.Core/3.3/ParameterizedNamedItem.cs	(revision 4790)
@@ -24,4 +24,5 @@
 using HeuristicLab.Common;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System.Linq.Expressions;
 
 namespace HeuristicLab.Core {
@@ -33,5 +34,5 @@
   public abstract class ParameterizedNamedItem : NamedItem, IParameterizedNamedItem {
     [Storable]
-    private List<IItemBinding> parameterBindingList;
+    protected List<IItemBinding> parameterBindingList;
     public List<IItemBinding> ParameterBindingList {
       get { return parameterBindingList; }
@@ -55,5 +56,4 @@
       : base(original, cloner) {
       parameters = cloner.Clone(original.parameters);
-      parameterBindingList = original.parameterBindingList.Select(x => cloner.Clone(x)).ToList();
       readOnlyParameters = null;
     }
@@ -111,4 +111,10 @@
     }
 
+    protected virtual void AddBinding(string targetPath, string sourcePath, LambdaExpression func) {
+      ItemBinding binding = new ItemBinding(this, targetPath, this, sourcePath, func);
+      parameterBindingList.Add(binding);
+      binding.Bind();
+    }
+
     protected virtual void AddSourceBinding(IDeepCloneable target, string targetPath, string sourcePath) {
       ItemBinding binding = new ItemBinding(target, targetPath, this, sourcePath);
Index: /branches/ParameterBinding/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
===================================================================
--- /branches/ParameterBinding/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs	(revision 4789)
+++ /branches/ParameterBinding/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs	(revision 4790)
@@ -33,4 +33,5 @@
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 using HeuristicLab.PluginInfrastructure;
+using System.Linq.Expressions;
 
 namespace HeuristicLab.Problems.TravelingSalesman {
@@ -148,5 +149,7 @@
     }
     public override IDeepCloneable Clone(Cloner cloner) {
-      return new TravelingSalesmanProblem(this, cloner);
+      TravelingSalesmanProblem clone = new TravelingSalesmanProblem(this, cloner);
+      clone.parameterBindingList = this.parameterBindingList.Select(x => cloner.Clone(x)).ToList();
+      return clone;
     }
     public TravelingSalesmanProblem()
@@ -178,5 +181,9 @@
       InitializeOperators();
       AttachEventHandlers();
-
+      CreateBindings();
+    }
+
+    private void CreateBindings() {
+      #region Analyzers
       AddBinding("BestTSPSolutionAnalyzer.QualityParameter.ActualName", "Evaluator.QualityParameter.ActualName");
       AddBinding("BestTSPSolutionAnalyzer.CoordinatesParameter.ActualName", "CoordinatesParameter.Name");
@@ -185,5 +192,17 @@
       AddBinding("BestTSPSolutionAnalyzer.BestKnownSolutionParameter.ActualName", "BestKnownSolutionParameter.Name");
       AddBinding("BestTSPSolutionAnalyzer.MaximizationParameter.ActualName", "MaximizationParameter.Name");
-      BestTSPSolutionAnalyzer.ResultsParameter.ActualName = "Results";
+      AddBinding("TSPAlleleFrequencyAnalyzer.MaximizationParameter.ActualName", "MaximizationParameter.Name");
+      AddBinding("TSPAlleleFrequencyAnalyzer.CoordinatesParameter.ActualName", "CoordinatesParameter.Name");
+      AddBinding("TSPAlleleFrequencyAnalyzer.SolutionParameter.ActualName", "SolutionCreator.PermutationParameter.ActualName");
+      AddBinding("TSPAlleleFrequencyAnalyzer.QualityParameter.ActualName", "Evaluator.QualityParameter.ActualName");
+      AddBinding("TSPAlleleFrequencyAnalyzer.BestKnownSolutionParameter.ActualName", "BestKnownSolutionParameter.Name");
+      AddBinding("TSPPopulationDiversityAnalyzer.MaximizationParameter.ActualName", "MaximizationParameter.Name");
+      AddBinding("TSPPopulationDiversityAnalyzer.SolutionParameter.ActualName", "SolutionCreator.PermutationParameter.ActualName");
+      AddBinding("TSPPopulationDiversityAnalyzer.QualityParameter.ActualName", "Evaluator.QualityParameter.ActualName");
+      #endregion
+      Expression<Func<IEnumerable<string>,IntValue>> tmp = (x) => new IntValue(x.Count());
+      AddBinding("SolutionCreator.LengthParameter.Value", "Coordinates.RowNames", tmp);
+      Expression<Func<IPermutationCreator, PermutationType>> tmp2 = (x) => new PermutationType(PermutationTypes.RelativeUndirected);
+      AddBinding("SolutionCreator.PermutationTypeParameter.Value", "SolutionCreator", tmp2);
     }
 
@@ -227,5 +246,4 @@
       ParameterizeSolutionCreator();
       ParameterizeEvaluator();
-      ParameterizeAnalyzers();
       ParameterizeOperators();
       OnSolutionCreatorChanged();
@@ -233,17 +251,11 @@
     private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
       ParameterizeEvaluator();
-      ParameterizeAnalyzers();
       ParameterizeOperators();
     }
     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
-      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
       ParameterizeEvaluator();
       UpdateMoveEvaluators();
-      ParameterizeAnalyzers();
       ClearDistanceMatrix();
       OnEvaluatorChanged();
-    }
-    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
-      ParameterizeAnalyzers();
     }
     private void MoveGenerator_InversionMoveParameter_ActualNameChanged(object sender, EventArgs e) {
@@ -278,5 +290,4 @@
       SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
       EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
-      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     }
 
@@ -286,5 +297,7 @@
       operators.Add(new TSPAlleleFrequencyAnalyzer());
       operators.Add(new TSPPopulationDiversityAnalyzer());
-      ParameterizeAnalyzers();
+      BestTSPSolutionAnalyzer.ResultsParameter.ActualName = "Results";
+      TSPAlleleFrequencyAnalyzer.ResultsParameter.ActualName = "Results";
+      TSPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
       operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Cast<IOperator>());
       ParameterizeOperators();
@@ -314,6 +327,6 @@
     }
     private void ParameterizeSolutionCreator() {
-      SolutionCreator.LengthParameter.Value = new IntValue(Coordinates.Rows);
-      SolutionCreator.PermutationTypeParameter.Value = new PermutationType(PermutationTypes.RelativeUndirected);
+      //SolutionCreator.LengthParameter.Value = new IntValue(Coordinates.Rows);
+      //SolutionCreator.PermutationTypeParameter.Value = new PermutationType(PermutationTypes.RelativeUndirected);
     }
     private void ParameterizeEvaluator() {
@@ -325,31 +338,4 @@
         evaluator.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name;
         evaluator.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name;
-      }
-    }
-    private void ParameterizeAnalyzers() {
-      /*if (BestTSPSolutionAnalyzer != null) {
-        BestTSPSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
-        BestTSPSolutionAnalyzer.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
-        BestTSPSolutionAnalyzer.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
-        BestTSPSolutionAnalyzer.ResultsParameter.ActualName = "Results";
-        BestTSPSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
-        BestTSPSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
-        BestTSPSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
-      }*/
-
-      if (TSPAlleleFrequencyAnalyzer != null) {
-        TSPAlleleFrequencyAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
-        TSPAlleleFrequencyAnalyzer.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
-        TSPAlleleFrequencyAnalyzer.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
-        TSPAlleleFrequencyAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
-        TSPAlleleFrequencyAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
-        TSPAlleleFrequencyAnalyzer.ResultsParameter.ActualName = "Results";
-      }
-
-      if (TSPPopulationDiversityAnalyzer != null) {
-        TSPPopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
-        TSPPopulationDiversityAnalyzer.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
-        TSPPopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
-        TSPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
       }
     }
