Changeset 2756 for trunk/sources/HeuristicLab.Operators
- Timestamp:
- 02/05/10 05:23:56 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Operators/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators/3.3/Counter.cs
r2740 r2756 36 36 [Creatable("Test")] 37 37 public sealed class Counter : SingleSuccessorOperator { 38 public ItemParameter<IntData> Value{39 get { return ( ItemParameter<IntData>)Parameters["Value"]; }38 public LookupParameter<IntData> ValueParameter { 39 get { return (LookupParameter<IntData>)Parameters["Value"]; } 40 40 } 41 public ItemParameter<IntData> Increment { 42 get { return (ItemParameter<IntData>)Parameters["Increment"]; } 41 public ValueLookupParameter<IntData> IncrementParaneter { 42 get { return (ValueLookupParameter<IntData>)Parameters["Increment"]; } 43 } 44 public IntData Increment { 45 get { return IncrementParaneter.Value; } 46 set { IncrementParaneter.Value = value; } 43 47 } 44 48 45 49 public Counter() 46 50 : base() { 47 Parameters.Add(new ItemParameter<IntData>("Value", "The value which should be incremented."));48 Parameters.Add(new ItemParameter<IntData>("Increment", "The increment which is added to the value.", new IntData(1)));51 Parameters.Add(new LookupParameter<IntData>("Value", "The value which should be incremented.")); 52 Parameters.Add(new ValueLookupParameter<IntData>("Increment", "The increment which is added to the value.", new IntData(1))); 49 53 } 50 54 51 55 public override ExecutionContextCollection Apply() { 52 IntData value = (IntData)Value.Value; 53 IntData increment = (IntData)Increment.Value; 54 value.Value += increment.Value; 56 if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntData(); 57 ValueParameter.ActualValue.Value += IncrementParaneter.ActualValue.Value; 55 58 return base.Apply(); 56 59 } -
trunk/sources/HeuristicLab.Operators/3.3/MultipleSuccessorsOperator.cs
r2740 r2756 38 38 [EmptyStorableClass] 39 39 public abstract class MultipleSuccessorsOperator : Operator { 40 protected I OperatorParameter[] SuccessorParameters {40 protected IValueParameter<IOperator>[] SuccessorParameters { 41 41 get { 42 42 return (from p in Parameters 43 where p is I OperatorParameter43 where p is IValueParameter<IOperator> 44 44 orderby p.Name ascending 45 select (I OperatorParameter)p).ToArray();45 select (IValueParameter<IOperator>)p).ToArray(); 46 46 } 47 47 } … … 53 53 successors = new OperatorList(); 54 54 var opParams = SuccessorParameters; 55 foreach (I OperatorParameteropParam in opParams) {55 foreach (IValueParameter<IOperator> opParam in opParams) { 56 56 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 57 57 successors.Add(opParam.Value); … … 73 73 private void UpdateOperatorParameters() { 74 74 var opParams = SuccessorParameters; 75 foreach (I OperatorParameteropParam in opParams) {75 foreach (IValueParameter<IOperator> opParam in opParams) { 76 76 opParam.ValueChanged -= new EventHandler(opParam_ValueChanged); 77 77 Parameters.Remove(opParam.Name); 78 78 } 79 79 for (int i = 0; i < Successors.Count; i++) { 80 I OperatorParameteropParam = new OperatorParameter(i.ToString(), string.Empty, Successors[i]);80 IValueParameter<IOperator> opParam = new OperatorParameter(i.ToString(), string.Empty, Successors[i]); 81 81 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 82 82 Parameters.Add(opParam); … … 92 92 private void successors_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) { 93 93 foreach (IndexedItem<IOperator> item in e.Items) 94 ((I OperatorParameter)Parameters[item.Index.ToString()]).Value = item.Value;94 ((IValueParameter<IOperator>)Parameters[item.Index.ToString()]).Value = item.Value; 95 95 } 96 96 private void successors_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) { 97 97 foreach (IndexedItem<IOperator> item in e.Items) 98 ((I OperatorParameter)Parameters[item.Index.ToString()]).Value = item.Value;98 ((IValueParameter<IOperator>)Parameters[item.Index.ToString()]).Value = item.Value; 99 99 } 100 100 private void successors_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) { … … 102 102 } 103 103 private void opParam_ValueChanged(object sender, EventArgs e) { 104 I OperatorParameter opParam = (IOperatorParameter)sender;104 IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender; 105 105 int index = int.Parse(opParam.Name); 106 106 successors[index] = opParam.Value;
Note: See TracChangeset
for help on using the changeset viewer.