- Timestamp:
- 10/29/10 16:58:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Optimization/3.3/Algorithm.cs
r4437 r4665 165 165 storeAlgorithmInEachRun = true; 166 166 } 167 168 167 [StorableHook(HookType.AfterDeserialization)] 168 private void AfterDeserialization() { 169 Initialize(); 170 } 171 172 protected Algorithm(Algorithm original, Cloner cloner) 173 : base(original, cloner) { 174 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 175 executionState = original.executionState; 176 executionTime = original.executionTime; 177 problem = cloner.Clone(original.problem); 178 storeAlgorithmInEachRun = original.storeAlgorithmInEachRun; 179 runsCounter = original.runsCounter; 180 runs = cloner.Clone(original.runs); 181 Initialize(); 182 } 183 169 184 private void Initialize() { 170 185 if (problem != null) RegisterProblemEvents(); 171 186 if (runs != null) RegisterRunsEvents(); 172 }173 174 public override IDeepCloneable Clone(Cloner cloner) {175 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));176 Algorithm clone = (Algorithm)base.Clone(cloner);177 clone.executionState = executionState;178 clone.executionTime = executionTime;179 clone.problem = (IProblem)cloner.Clone(problem);180 clone.storeAlgorithmInEachRun = storeAlgorithmInEachRun;181 clone.runsCounter = runsCounter;182 clone.runs = (RunCollection)cloner.Clone(runs);183 clone.Initialize();184 return clone;185 }186 protected virtual void Clone(IDeepCloneable clone, Cloner cloner) {187 Algorithm algorithm = clone as Algorithm;188 if (algorithm != null) {189 algorithm.name = name;190 algorithm.description = description;191 foreach (IParameter param in Parameters)192 algorithm.Parameters.Add((IParameter)cloner.Clone(param));193 algorithm.executionState = executionState;194 algorithm.executionTime = executionTime;195 algorithm.problem = (IProblem)cloner.Clone(problem);196 algorithm.storeAlgorithmInEachRun = storeAlgorithmInEachRun;197 algorithm.runsCounter = runsCounter;198 algorithm.runs = (RunCollection)cloner.Clone(runs);199 algorithm.Initialize();200 }201 187 } 202 188
Note: See TracChangeset
for help on using the changeset viewer.