Changeset 8357 for trunk/sources/HeuristicLab.Operators
- Timestamp:
- 07/30/12 13:36:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Operators/3.3/SubScopesCounter.cs ¶
r7259 r8357 34 34 get { return (ILookupParameter<IntValue>)Parameters["Value"]; } 35 35 } 36 public IValueParameter<BoolValue> AccumulateParameter { 37 get { return (IValueParameter<BoolValue>)Parameters["Accumulate"]; } 38 } 36 39 37 40 [StorableConstructor] … … 42 45 public SubScopesCounter() { 43 46 Parameters.Add(new LookupParameter<IntValue>("Value", "The value that should be incremented by the number of direct sub-scopes. It will be created in the current scope if the value is not found.")); 47 Parameters.Add(new ValueParameter<BoolValue>("Accumulate", ".", new BoolValue(true))); 48 } 49 50 [StorableHook(HookType.AfterDeserialization)] 51 private void AfterDeserialization() { 52 if (!Parameters.ContainsKey("Accumulate")) 53 Parameters.Add(new ValueParameter<BoolValue>("Accumulate", ".", new BoolValue(true))); 44 54 } 45 55 … … 49 59 50 60 public override IOperation Apply() { 51 int increment = ExecutionContext.Scope.SubScopes.Count;61 int count = ExecutionContext.Scope.SubScopes.Count; 52 62 if (ValueParameter.ActualValue == null) ValueParameter.ActualValue = new IntValue(); 53 ValueParameter.ActualValue.Value += increment; 63 if (AccumulateParameter.Value.Value) ValueParameter.ActualValue.Value += count; 64 else ValueParameter.ActualValue.Value = count; 54 65 return base.Apply(); 55 66 }
Note: See TracChangeset
for help on using the changeset viewer.