- Timestamp:
- 10/29/10 17:38:42 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Core/3.3/Scope.cs
r4489 r4668 59 59 } 60 60 61 [StorableConstructor] 62 private Scope(bool deserializing) : base(deserializing) { } 63 private Scope(Scope original, Cloner cloner) 64 : base(original, cloner) { 65 if (original.variables.Count > 0) variables = cloner.Clone(original.variables); 66 if (original.subScopes.Count > 0) { 67 subScopes = cloner.Clone(original.subScopes); 68 foreach (IScope child in SubScopes) 69 child.Parent = this; 70 RegisterSubScopesEvents(); 71 } 72 } 61 73 /// <summary> 62 74 /// Initializes a new instance of <see cref="Scope"/> having "Anonymous" as default name. … … 67 79 variables = new VariableCollection(); 68 80 subScopes = new ScopeList(); 69 Initialize();81 RegisterSubScopesEvents(); 70 82 } 71 83 /// <summary> … … 78 90 variables = new VariableCollection(); 79 91 subScopes = new ScopeList(); 80 Initialize();92 RegisterSubScopesEvents(); 81 93 } 82 94 public Scope(string name, string description) … … 85 97 variables = new VariableCollection(); 86 98 subScopes = new ScopeList(); 87 Initialize();99 RegisterSubScopesEvents(); 88 100 } 89 [StorableConstructor]90 private Scope(bool deserializing) : base(deserializing) { }91 101 92 102 [StorableHook(HookType.AfterDeserialization)] 93 private void Initialize() {103 private void AfterDeserialization() { 94 104 RegisterSubScopesEvents(); 95 105 } … … 103 113 /// <inheritdoc/> 104 114 public override IDeepCloneable Clone(Cloner cloner) { 105 Scope clone = new Scope(); 106 cloner.RegisterClonedObject(this, clone); 107 clone.name = name; 108 clone.description = description; 109 if (variables.Count > 0) clone.variables = (VariableCollection)cloner.Clone(variables); 110 if (subScopes.Count > 0) { 111 clone.subScopes = (ScopeList)cloner.Clone(subScopes); 112 foreach (IScope child in clone.SubScopes) 113 child.Parent = clone; 114 clone.Initialize(); 115 } 116 return clone; 115 return new Scope(this, cloner); 117 116 } 118 117
Note: See TracChangeset
for help on using the changeset viewer.