- Timestamp:
- 08/05/10 10:54:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r4068 r4164 34 34 [StorableClass] 35 35 public class RunCollection : ItemCollection<IRun>, IStringConvertibleMatrix { 36 [StorableConstructor] 37 protected RunCollection(bool deserializing) : base(deserializing) { } 36 38 public RunCollection() : base() { Initialize(); } 37 39 public RunCollection(int capacity) : base(capacity) { Initialize(); } … … 42 44 dataTypes = new Dictionary<string, HashSet<Type>>(); 43 45 constraints = new RunCollectionConstraintCollection(); 44 constraints.ItemsAdded += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsAdded); 45 constraints.ItemsRemoved += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsRemoved); 46 constraints.CollectionReset += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_CollectionReset); 47 } 46 RegisterConstraintsEvents(); 47 } 48 48 49 [Storable] 49 50 private Dictionary<string, HashSet<Type>> dataTypes; … … 53 54 return dataTypes[columnName]; 54 55 } 56 57 [Storable] 55 58 private RunCollectionConstraintCollection constraints; 56 59 public RunCollectionConstraintCollection Constraints { … … 160 163 } 161 164 165 [StorableHook(HookType.AfterDeserialization)] 166 private void AfterDeserializationHook() { 167 if (constraints == null) constraints = new RunCollectionConstraintCollection(); 168 RegisterConstraintsEvents(); 169 UpdateFiltering(true); 170 } 162 171 163 172 public override IDeepCloneable Clone(Cloner cloner) { … … 168 177 foreach (string s in this.dataTypes.Keys) 169 178 clone.dataTypes[s] = new HashSet<Type>(this.dataTypes[s]); 179 180 clone.constraints = new RunCollectionConstraintCollection(this.constraints.Select(x => (IRunCollectionConstraint)cloner.Clone(x))); 181 foreach (IRunCollectionConstraint constraint in clone.constraints) 182 constraint.ConstrainedValue = clone; 183 clone.RegisterConstraintsEvents(); 184 clone.RegisterConstraintEvents(clone.constraints); 185 186 clone.UpdateFiltering(true); 170 187 return clone; 171 188 } … … 261 278 } 262 279 280 private void RegisterConstraintsEvents() { 281 constraints.ItemsAdded += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsAdded); 282 constraints.ItemsRemoved += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsRemoved); 283 constraints.CollectionReset += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_CollectionReset); 284 } 285 263 286 protected virtual void RegisterConstraintEvents(IEnumerable<IRunCollectionConstraint> constraints) { 264 287 foreach (IRunCollectionConstraint constraint in constraints) {
Note: See TracChangeset
for help on using the changeset viewer.