Changeset 4722 for trunk/sources/HeuristicLab.Core/3.3/Collections
- Timestamp:
- 11/06/10 01:56:04 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/CloningRefactoring (added) merged: 4656-4693,4696-4697,4711-4714,4718-4719
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Core/3.3/Collections/CheckedItemCollection.cs
r4068 r4722 46 46 47 47 /// <summary> 48 /// Instantiates an empty CheckedItemCollection for deserialization. 49 /// </summary> 50 /// <param name="deserializing"></param> 51 [StorableConstructor] 52 protected CheckedItemCollection(bool deserializing) : base(deserializing) { } 53 protected CheckedItemCollection(CheckedItemCollection<T> original, Cloner cloner) 54 : base(original, cloner) { 55 list = new List<T>(original.Select(x => cloner.Clone(x))); 56 checkedState = new Dictionary<T, bool>(); 57 foreach (var pair in original.checkedState) 58 checkedState.Add(cloner.Clone(pair.Key), pair.Value); 59 } 60 /// <summary> 48 61 /// Instantiates a new CheckedItemCollection. 49 62 /// </summary> … … 71 84 checkedState.Add(item, true); 72 85 } 73 /// <summary>74 /// Instantiates an empty CheckedItemCollection for deserialization.75 /// </summary>76 /// <param name="deserializing"></param>77 [StorableConstructor]78 protected CheckedItemCollection(bool deserializing) : base(deserializing) { }79 86 80 87 /// <summary> … … 179 186 /// <returns>A clone of the CheckedItemCollection</returns> 180 187 public override IDeepCloneable Clone(Cloner cloner) { 181 CheckedItemCollection<T> clone = (CheckedItemCollection<T>)Activator.CreateInstance(this.GetType()); 182 cloner.RegisterClonedObject(this, clone); 183 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 184 clone.checkedState = new Dictionary<T, bool>(); 185 foreach (var pair in checkedState) 186 clone.checkedState.Add((T)cloner.Clone(pair.Key), pair.Value); 187 return clone; 188 return new CheckedItemCollection<T>(this, cloner); 188 189 } 189 190 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/CheckedItemList.cs
r4068 r4722 48 48 } 49 49 } 50 51 /// <summary> 52 /// Instantiates a new CheckedItemList for deserialization. 53 /// </summary> 54 /// <param name="deserializing"></param> 55 [StorableConstructor] 56 protected CheckedItemList(bool deserializing) : base(deserializing) { } 57 protected CheckedItemList(CheckedItemList<T> original, Cloner cloner) 58 : base(original, cloner) { 59 list = new List<T>(original.Select(x => (T)cloner.Clone(x))); 60 checkedState = new Dictionary<T, bool>(); 61 foreach (var pair in original.checkedState) 62 checkedState.Add(cloner.Clone(pair.Key), pair.Value); 63 } 50 64 /// <summary> 51 65 /// Instantiates an empty CheckedItemList. … … 75 89 } 76 90 } 77 /// <summary>78 /// Instantiates a new CheckedItemList for deserialization.79 /// </summary>80 /// <param name="deserializing"></param>81 [StorableConstructor]82 protected CheckedItemList(bool deserializing) : base(deserializing) { }83 91 84 92 /// <summary> … … 228 236 /// <returns>A deep clone of the CheckedItemList</returns> 229 237 public override IDeepCloneable Clone(Cloner cloner) { 230 CheckedItemList<T> clone = (CheckedItemList<T>)Activator.CreateInstance(this.GetType()); 231 cloner.RegisterClonedObject(this, clone); 232 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 233 clone.checkedState = new Dictionary<T, bool>(); 234 foreach (var pair in checkedState) 235 clone.checkedState.Add((T)cloner.Clone(pair.Key), pair.Value); 236 return clone; 238 return new CheckedItemList<T>(this, cloner); 237 239 } 238 240 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ConstraintCollection.cs
r4068 r4722 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 27 28 [Item("ConstraintCollection", "Represents a collection of constraints.")] 28 29 public class ConstraintCollection : ItemCollection<IConstraint> { 30 [StorableConstructor] 31 protected ConstraintCollection(bool deserializing) : base(deserializing) { } 32 protected ConstraintCollection(ConstraintCollection original, Cloner cloner) : base(original, cloner) { } 29 33 public ConstraintCollection() : base() { } 30 34 public ConstraintCollection(int capacity) : base(capacity) { } 31 35 public ConstraintCollection(IEnumerable<IConstraint> collection) : base(collection) { } 32 [StorableConstructor] 33 p rotected ConstraintCollection(bool deserializing) : base(deserializing) {}36 37 public override IDeepCloneable Clone(Cloner cloner) { return new ConstraintCollection(this, cloner); } 34 38 } 35 39 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemArray.cs
r4419 r4722 46 46 } 47 47 48 [StorableConstructor] 49 protected ItemArray(bool deserializing) : base(deserializing) { } 50 protected ItemArray(ItemArray<T> original, Cloner cloner) { 51 cloner.RegisterClonedObject(original, this); 52 array = original.Select(x => cloner.Clone(x)).ToArray(); 53 } 48 54 public ItemArray() : base() { } 49 55 public ItemArray(int length) : base(length) { } 50 56 public ItemArray(T[] array) : base(array) { } 51 57 public ItemArray(IEnumerable<T> collection) : base(collection) { } 52 [StorableConstructor]53 protected ItemArray(bool deserializing) : base(deserializing) { }54 58 55 59 public object Clone() { … … 57 61 } 58 62 public virtual IDeepCloneable Clone(Cloner cloner) { 59 ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType()); 60 cloner.RegisterClonedObject(this, clone); 61 clone.array = this.Select(x => (T)cloner.Clone(x)).ToArray(); 62 return clone; 63 return new ItemArray<T>(this, cloner); 63 64 } 64 65 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemCollection.cs
r4419 r4722 46 46 } 47 47 48 [StorableConstructor] 49 protected ItemCollection(bool deserializing) : base(deserializing) { } 50 protected ItemCollection(ItemCollection<T> original, Cloner cloner) { 51 cloner.RegisterClonedObject(original, this); 52 list = new List<T>(original.Select(x => cloner.Clone(x))); 53 } 48 54 public ItemCollection() : base() { } 49 55 public ItemCollection(int capacity) : base(capacity) { } 50 56 public ItemCollection(IEnumerable<T> collection) : base(collection) { } 51 [StorableConstructor]52 protected ItemCollection(bool deserializing) : base(deserializing) { }53 57 54 58 public object Clone() { … … 56 60 } 57 61 public virtual IDeepCloneable Clone(Cloner cloner) { 58 ItemCollection<T> clone = (ItemCollection<T>)Activator.CreateInstance(this.GetType()); 59 cloner.RegisterClonedObject(this, clone); 60 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 61 return clone; 62 return new ItemCollection<T>(this, cloner); 62 63 } 63 64 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemDictionary.cs
r4419 r4722 48 48 } 49 49 50 [StorableConstructor] 51 protected ItemDictionary(bool deserializing) : base(deserializing) { } 52 protected ItemDictionary(ItemDictionary<TKey, TValue> original, Cloner cloner) { 53 cloner.RegisterClonedObject(original, this); 54 foreach (TKey key in dict.Keys) 55 dict.Add(cloner.Clone(key), cloner.Clone(dict[key])); 56 } 50 57 public ItemDictionary() : base() { } 51 58 public ItemDictionary(int capacity) : base(capacity) { } 52 59 public ItemDictionary(IDictionary<TKey, TValue> dictionary) : base(dictionary) { } 53 [StorableConstructor]54 protected ItemDictionary(bool deserializing) : base(deserializing) { }55 60 56 61 public object Clone() { … … 58 63 } 59 64 public virtual IDeepCloneable Clone(Cloner cloner) { 60 ItemDictionary<TKey, TValue> clone = (ItemDictionary<TKey, TValue>)Activator.CreateInstance(this.GetType()); 61 cloner.RegisterClonedObject(this, clone); 62 foreach (TKey key in dict.Keys) 63 clone.dict.Add((TKey)cloner.Clone(key), (TValue)cloner.Clone(dict[key])); 64 return clone; 65 return new ItemDictionary<TKey, TValue>(this, cloner); 65 66 } 66 67 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemList.cs
r4419 r4722 46 46 } 47 47 48 [StorableConstructor] 49 protected ItemList(bool deserializing) : base(deserializing) { } 50 protected ItemList(ItemList<T> original, Cloner cloner) { 51 cloner.RegisterClonedObject(original, this); 52 list = new List<T>(original.Select(x => cloner.Clone(x))); 53 } 48 54 public ItemList() : base() { } 49 55 public ItemList(int capacity) : base(capacity) { } 50 56 public ItemList(IEnumerable<T> collection) : base(collection) { } 51 [StorableConstructor]52 protected ItemList(bool deserializing) : base(deserializing) { }53 57 54 58 public object Clone() { … … 56 60 } 57 61 public virtual IDeepCloneable Clone(Cloner cloner) { 58 ItemList<T> clone = (ItemList<T>)Activator.CreateInstance(this.GetType()); 59 cloner.RegisterClonedObject(this, clone); 60 clone.list = new List<T>(this.Select(x => (T)cloner.Clone(x))); 61 return clone; 62 return new ItemList<T>(this, cloner); 62 63 } 63 64 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ItemSet.cs
r4419 r4722 46 46 } 47 47 48 [StorableConstructor] 49 protected ItemSet(bool deserializing) : base(deserializing) { } 50 protected ItemSet(ItemSet<T> original, Cloner cloner) { 51 cloner.RegisterClonedObject(original, this); 52 set = new HashSet<T>(original.Select(x => cloner.Clone(x))); 53 } 48 54 public ItemSet() : base() { } 49 55 public ItemSet(IEnumerable<T> collection) : base(collection) { } 50 [StorableConstructor]51 protected ItemSet(bool deserializing) : base(deserializing) { }52 56 53 57 public object Clone() { … … 55 59 } 56 60 public virtual IDeepCloneable Clone(Cloner cloner) { 57 ItemSet<T> clone = (ItemSet<T>)Activator.CreateInstance(this.GetType()); 58 cloner.RegisterClonedObject(this, clone); 59 clone.set = new HashSet<T>(this.Select(x => (T)cloner.Clone(x))); 60 return clone; 61 return new ItemSet<T>(this, cloner); 61 62 } 62 63 -
trunk/sources/HeuristicLab.Core/3.3/Collections/KeyedItemCollection.cs
r4419 r4722 44 44 } 45 45 46 [StorableConstructor] 47 protected KeyedItemCollection(bool deserializing) : base(deserializing) { } 48 protected KeyedItemCollection(KeyedItemCollection<TKey, TItem> original, Cloner cloner) { 49 cloner.RegisterClonedObject(original, this); 50 foreach (TItem item in original.dict.Values) { 51 TItem clonedItem = cloner.Clone(item); 52 dict.Add(GetKeyForItem(clonedItem), clonedItem); 53 } 54 } 46 55 protected KeyedItemCollection() : base() { } 47 56 protected KeyedItemCollection(int capacity) : base(capacity) { } 48 57 protected KeyedItemCollection(IEnumerable<TItem> collection) : base(collection) { } 49 [StorableConstructor]50 protected KeyedItemCollection(bool deserializing) : base(deserializing) { }51 58 52 59 public object Clone() { 53 60 return Clone(new Cloner()); 54 61 } 55 public virtual IDeepCloneable Clone(Cloner cloner) { 56 KeyedItemCollection<TKey, TItem> clone = (KeyedItemCollection<TKey, TItem>)Activator.CreateInstance(this.GetType()); 57 cloner.RegisterClonedObject(this, clone); 58 foreach (TItem item in dict.Values) { 59 TItem clonedItem = (TItem)cloner.Clone(item); 60 clone.dict.Add(GetKeyForItem(clonedItem), clonedItem); 61 } 62 return clone; 63 } 62 public abstract IDeepCloneable Clone(Cloner cloner); 64 63 65 64 public new ReadOnlyKeyedItemCollection<TKey, TItem> AsReadOnly() { -
trunk/sources/HeuristicLab.Core/3.3/Collections/NamedItemCollection.cs
r4068 r4722 29 29 [StorableClass] 30 30 public class NamedItemCollection<T> : KeyedItemCollection<string, T> where T : class, INamedItem { 31 [StorableConstructor] 32 protected NamedItemCollection(bool deserializing) : base(deserializing) { } 33 protected NamedItemCollection(NamedItemCollection<T> original, Cloner cloner) 34 : base(original, cloner) { 35 RegisterItemEvents(this); 36 } 31 37 public NamedItemCollection() : base() { } 32 38 public NamedItemCollection(int capacity) : base(capacity) { } 33 39 public NamedItemCollection(IEnumerable<T> collection) 34 40 : base(collection) { 35 Initialize();41 RegisterItemEvents(this); 36 42 } 37 [StorableConstructor]38 protected NamedItemCollection(bool deserializing) : base(deserializing) { }39 43 40 44 [StorableHook(HookType.AfterDeserialization)] 41 pr otected void Initialize() {45 private void AfterDeserialization() { 42 46 RegisterItemEvents(this); 43 47 } 44 48 45 49 public override IDeepCloneable Clone(Cloner cloner) { 46 NamedItemCollection<T> clone = (NamedItemCollection<T>)base.Clone(cloner); 47 clone.Initialize(); 48 return clone; 50 return new NamedItemCollection<T>(this, cloner); 49 51 } 50 52 … … 73 75 } 74 76 75 pr ivatevoid RegisterItemEvents(IEnumerable<T> items) {77 protected void RegisterItemEvents(IEnumerable<T> items) { 76 78 foreach (T item in items) { 77 79 if (item != null) { -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperationCollection.cs
r3390 r4722 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 39 38 } 40 39 40 [StorableConstructor] 41 private OperationCollection(bool deserializing) { } 42 private OperationCollection(OperationCollection original, Cloner cloner) 43 : base(original, cloner) { 44 operations = new List<IOperation>(original.Select(x => cloner.Clone(x))); 45 parallel = original.parallel; 46 } 41 47 public OperationCollection() { 42 48 operations = new List<IOperation>(); … … 51 57 parallel = false; 52 58 } 53 [StorableConstructor]54 private OperationCollection(bool deserializing) { }55 59 56 60 public override IDeepCloneable Clone(Cloner cloner) { 57 OperationCollection clone = (OperationCollection)Activator.CreateInstance(this.GetType()); 58 cloner.RegisterClonedObject(this, clone); 59 clone.operations = new List<IOperation>(this.Select(x => (IOperation)cloner.Clone(x))); 60 clone.parallel = parallel; 61 return clone; 61 return new OperationCollection(this, cloner); 62 62 } 63 63 -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorCollection.cs
r4419 r4722 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 27 28 [Item("Operator Collection", "Represents a collection of operators.")] 28 29 public class OperatorCollection : ItemCollection<IOperator> { 30 [StorableConstructor] 31 protected OperatorCollection(bool deserializing) : base(deserializing) { } 32 protected OperatorCollection(OperatorCollection original, Cloner cloner) : base(original, cloner) { } 29 33 public OperatorCollection() : base() { } 30 34 public OperatorCollection(IEnumerable<IOperator> collection) : base(collection) { } 31 [StorableConstructor] 32 p rotected OperatorCollection(bool deserializing) : base(deserializing) {}35 36 public override IDeepCloneable Clone(Cloner cloner) { return new OperatorCollection(this, cloner); } 33 37 } 34 38 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorList.cs
r4068 r4722 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 27 28 [Item("OperatorList", "Represents a list of operators.")] 28 29 public class OperatorList : ItemList<IOperator> { 30 [StorableConstructor] 31 protected OperatorList(bool deserializing) : base(deserializing) { } 32 protected OperatorList(OperatorList original, Cloner cloner) : base(original, cloner) { } 29 33 public OperatorList() : base() { } 30 34 public OperatorList(int capacity) : base(capacity) { } 31 35 public OperatorList(IEnumerable<IOperator> collection) : base(collection) { } 32 [StorableConstructor] 33 p rotected OperatorList(bool deserializing) : base(deserializing) {}36 37 public override IDeepCloneable Clone(Cloner cloner) { return new OperatorList(this, cloner); } 34 38 } 35 39 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/OperatorSet.cs
r4068 r4722 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 27 28 [Item("OperatorSet", "Represents a set of operators.")] 28 29 public class OperatorSet : ItemSet<IOperator> { 30 [StorableConstructor] 31 protected OperatorSet(bool deserializing) : base(deserializing) { } 32 protected OperatorSet(OperatorSet original, Cloner cloner) : base(original, cloner) { } 29 33 public OperatorSet() : base() { } 30 34 public OperatorSet(IEnumerable<IOperator> collection) : base(collection) { } 31 [StorableConstructor] 32 p rotected OperatorSet(bool deserializing) : base(deserializing) {}35 36 public override IDeepCloneable Clone(Cloner cloner) { return new OperatorSet(this, cloner); } 33 37 } 34 38 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ParameterCollection.cs
r3390 r4722 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 27 28 [Item("ParameterCollection", "Represents a collection of parameters.")] 28 29 public class ParameterCollection : NamedItemCollection<IParameter> { 30 [StorableConstructor] 31 protected ParameterCollection(bool deserializing) : base(deserializing) { } 32 protected ParameterCollection(ParameterCollection original, Cloner cloner) : base(original, cloner) { } 29 33 public ParameterCollection() : base() { } 30 34 public ParameterCollection(int capacity) : base(capacity) { } 31 35 public ParameterCollection(IEnumerable<IParameter> collection) : base(collection) { } 32 [StorableConstructor] 33 p rotected ParameterCollection(bool deserializing) : base(deserializing) {}36 37 public override IDeepCloneable Clone(Cloner cloner) { return new ParameterCollection(this, cloner); } 34 38 } 35 39 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyCheckedItemCollection.cs
r4290 r4722 34 34 } 35 35 36 [StorableConstructor] 37 protected ReadOnlyCheckedItemCollection(bool deserializing) : base(deserializing) { } 38 protected ReadOnlyCheckedItemCollection(ReadOnlyCheckedItemCollection<T> original, Cloner cloner) 39 : base(original, cloner) { 40 CheckedItemCollection.CheckedItemsChanged += new CollectionItemsChangedEventHandler<T>(collection_CheckedItemsChanged); 41 } 36 42 public ReadOnlyCheckedItemCollection() : base(new CheckedItemCollection<T>()) { } 37 43 public ReadOnlyCheckedItemCollection(ICheckedItemCollection<T> collection) … … 40 46 } 41 47 42 [StorableConstructor]43 protected ReadOnlyCheckedItemCollection(bool deserializing) : base(deserializing) { }44 48 [StorableHook(HookType.AfterDeserialization)] 45 private void AfterDeserialization Hook() {49 private void AfterDeserialization() { 46 50 CheckedItemCollection.CheckedItemsChanged += new CollectionItemsChangedEventHandler<T>(collection_CheckedItemsChanged); 47 51 } 48 52 49 public override IDeepCloneable Clone(Common.Cloner cloner) { 50 ReadOnlyCheckedItemCollection<T> clone = (ReadOnlyCheckedItemCollection<T>)base.Clone(cloner); 51 clone.CheckedItemCollection.CheckedItemsChanged += new CollectionItemsChangedEventHandler<T>(clone.collection_CheckedItemsChanged); 52 return clone; 53 public override IDeepCloneable Clone(Cloner cloner) { 54 return new ReadOnlyCheckedItemCollection<T>(this, cloner); 53 55 } 54 56 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyCheckedItemList.cs
r4290 r4722 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Collections; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 … … 33 34 } 34 35 36 [StorableConstructor] 37 protected ReadOnlyCheckedItemList(bool deserializing) : base(deserializing) { } 38 protected ReadOnlyCheckedItemList(ReadOnlyCheckedItemList<T> original, Cloner cloner) 39 : base(original, cloner) { 40 CheckedItemList.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<T>>(list_CheckedItemsChanged); 41 } 35 42 public ReadOnlyCheckedItemList() : base(new CheckedItemList<T>()) { } 36 43 public ReadOnlyCheckedItemList(ICheckedItemList<T> list) … … 39 46 } 40 47 41 [StorableConstructor]42 protected ReadOnlyCheckedItemList(bool deserializing) : base(deserializing) { }43 48 [StorableHook(HookType.AfterDeserialization)] 44 private void AfterDeserialization Hook() {49 private void AfterDeserialization() { 45 50 CheckedItemList.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<T>>(list_CheckedItemsChanged); 46 51 } 47 52 48 public override Common.IDeepCloneable Clone(Common.Cloner cloner) { 49 ReadOnlyCheckedItemList<T> clone = (ReadOnlyCheckedItemList<T>)base.Clone(cloner); 50 clone.CheckedItemList.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<T>>(clone.list_CheckedItemsChanged); 51 return clone; 53 public override IDeepCloneable Clone(Cloner cloner) { 54 return new ReadOnlyCheckedItemList<T>(this, cloner); 52 55 } 53 56 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemArray.cs
r4419 r4722 44 44 } 45 45 46 [StorableConstructor] 47 protected ReadOnlyItemArray(bool deserializing) : base(deserializing) { } 48 protected ReadOnlyItemArray(ReadOnlyItemArray<T> original, Cloner cloner) { 49 cloner.RegisterClonedObject(original, this); 50 array = cloner.Clone((IItemArray<T>)original.array); 51 RegisterEvents(); 52 } 46 53 public ReadOnlyItemArray() : base(new ItemArray<T>()) { } 47 54 public ReadOnlyItemArray(IItemArray<T> array) : base(array) { } 48 [StorableConstructor]49 protected ReadOnlyItemArray(bool deserializing) : base(deserializing) { }50 55 51 56 public object Clone() { … … 53 58 } 54 59 public virtual IDeepCloneable Clone(Cloner cloner) { 55 ReadOnlyItemArray<T> clone = (ReadOnlyItemArray<T>)Activator.CreateInstance(this.GetType()); 56 cloner.RegisterClonedObject(this, clone); 57 clone.array = (IItemArray<T>)((IItemArray<T>)array).Clone(cloner); 58 clone.RegisterEvents(); 59 return clone; 60 return new ReadOnlyItemArray<T>(this, cloner); 60 61 } 61 62 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemCollection.cs
r4419 r4722 44 44 } 45 45 46 [StorableConstructor] 47 protected ReadOnlyItemCollection(bool deserializing) : base(deserializing) { } 48 protected ReadOnlyItemCollection(ReadOnlyItemCollection<T> original, Cloner cloner) { 49 cloner.RegisterClonedObject(original, this); 50 collection = cloner.Clone((IItemCollection<T>)original.collection); 51 RegisterEvents(); 52 } 46 53 public ReadOnlyItemCollection() : base(new ItemCollection<T>()) { } 47 54 public ReadOnlyItemCollection(IItemCollection<T> collection) : base(collection) { } 48 [StorableConstructor]49 protected ReadOnlyItemCollection(bool deserializing) : base(deserializing) { }50 55 51 56 public object Clone() { … … 53 58 } 54 59 public virtual IDeepCloneable Clone(Cloner cloner) { 55 ReadOnlyItemCollection<T> clone = (ReadOnlyItemCollection<T>)Activator.CreateInstance(this.GetType()); 56 cloner.RegisterClonedObject(this, clone); 57 clone.collection = (IItemCollection<T>)((IItemCollection<T>)collection).Clone(cloner); 58 clone.RegisterEvents(); 59 return clone; 60 return new ReadOnlyItemCollection<T>(this, cloner); 60 61 } 61 62 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemDictionary.cs
r4419 r4722 47 47 } 48 48 49 [StorableConstructor] 50 protected ReadOnlyItemDictionary(bool deserializing) : base(deserializing) { } 51 protected ReadOnlyItemDictionary(ReadOnlyItemDictionary<TKey, TValue> original, Cloner cloner) { 52 cloner.RegisterClonedObject(original, this); 53 dict = cloner.Clone((IItemDictionary<TKey, TValue>)original.dict); 54 RegisterEvents(); 55 } 49 56 public ReadOnlyItemDictionary() : base(new ItemDictionary<TKey, TValue>()) { } 50 57 public ReadOnlyItemDictionary(IItemDictionary<TKey, TValue> dictionary) : base(dictionary) { } 51 [StorableConstructor]52 protected ReadOnlyItemDictionary(bool deserializing) : base(deserializing) { }53 58 54 59 public object Clone() { … … 56 61 } 57 62 public virtual IDeepCloneable Clone(Cloner cloner) { 58 ReadOnlyItemDictionary<TKey, TValue> clone = (ReadOnlyItemDictionary<TKey, TValue>)Activator.CreateInstance(this.GetType()); 59 cloner.RegisterClonedObject(this, clone); 60 clone.dict = (IItemDictionary<TKey, TValue>)((IItemDictionary<TKey, TValue>)dict).Clone(cloner); 61 clone.RegisterEvents(); 62 return clone; 63 return new ReadOnlyItemDictionary<TKey, TValue>(this, cloner); 63 64 } 64 65 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemList.cs
r4419 r4722 44 44 } 45 45 46 [StorableConstructor] 47 protected ReadOnlyItemList(bool deserializing) : base(deserializing) { } 48 protected ReadOnlyItemList(ReadOnlyItemList<T> original, Cloner cloner) { 49 cloner.RegisterClonedObject(original, this); 50 list = cloner.Clone((IItemList<T>)original.list); 51 RegisterEvents(); 52 } 46 53 public ReadOnlyItemList() : base(new ItemList<T>()) { } 47 54 public ReadOnlyItemList(IItemList<T> list) : base(list) { } 48 [StorableConstructor]49 protected ReadOnlyItemList(bool deserializing) : base(deserializing) { }50 55 51 56 public object Clone() { … … 53 58 } 54 59 public virtual IDeepCloneable Clone(Cloner cloner) { 55 ReadOnlyItemList<T> clone = (ReadOnlyItemList<T>)Activator.CreateInstance(this.GetType()); 56 cloner.RegisterClonedObject(this, clone); 57 clone.list = (IItemList<T>)((IItemList<T>)list).Clone(cloner); 58 clone.RegisterEvents(); 59 return clone; 60 return new ReadOnlyItemList<T>(this, cloner); 60 61 } 61 62 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyItemSet.cs
r4419 r4722 44 44 } 45 45 46 [StorableConstructor] 47 protected ReadOnlyItemSet(bool deserializing) : base(deserializing) { } 48 protected ReadOnlyItemSet(ReadOnlyItemSet<T> original, Cloner cloner) { 49 cloner.RegisterClonedObject(original, this); 50 set = cloner.Clone((IItemSet<T>)original.set); 51 RegisterEvents(); 52 } 46 53 public ReadOnlyItemSet() : base(new ItemSet<T>()) { } 47 54 public ReadOnlyItemSet(IItemSet<T> set) : base(set) { } 48 [StorableConstructor]49 protected ReadOnlyItemSet(bool deserializing) : base(deserializing) { }50 55 51 56 public object Clone() { … … 53 58 } 54 59 public virtual IDeepCloneable Clone(Cloner cloner) { 55 ReadOnlyItemSet<T> clone = (ReadOnlyItemSet<T>)Activator.CreateInstance(this.GetType()); 56 cloner.RegisterClonedObject(this, clone); 57 clone.set = (IItemSet<T>)((IItemSet<T>)set).Clone(cloner); 58 clone.RegisterEvents(); 59 return clone; 60 return new ReadOnlyItemSet<T>(this, cloner); 60 61 } 61 62 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ReadOnlyKeyedItemCollection.cs
r4419 r4722 44 44 } 45 45 46 [StorableConstructor] 47 protected ReadOnlyKeyedItemCollection(bool deserializing) : base(deserializing) { } 48 protected ReadOnlyKeyedItemCollection(ReadOnlyKeyedItemCollection<TKey, TItem> original, Cloner cloner) { 49 cloner.RegisterClonedObject(original, this); 50 collection = cloner.Clone((IKeyedItemCollection<TKey, TItem>)original.collection); 51 RegisterEvents(); 52 } 46 53 protected ReadOnlyKeyedItemCollection() : base() { } 47 54 public ReadOnlyKeyedItemCollection(IKeyedItemCollection<TKey, TItem> collection) : base(collection) { } 48 [StorableConstructor]49 protected ReadOnlyKeyedItemCollection(bool deserializing) : base(deserializing) { }50 55 51 56 public object Clone() { … … 53 58 } 54 59 public virtual IDeepCloneable Clone(Cloner cloner) { 55 ReadOnlyKeyedItemCollection<TKey, TItem> clone = (ReadOnlyKeyedItemCollection<TKey, TItem>)Activator.CreateInstance(this.GetType()); 56 cloner.RegisterClonedObject(this, clone); 57 clone.collection = (IKeyedItemCollection<TKey, TItem>)((IKeyedItemCollection<TKey, TItem>)collection).Clone(cloner); 58 clone.RegisterEvents(); 59 return clone; 60 return new ReadOnlyKeyedItemCollection<TKey, TItem>(this, cloner); 60 61 } 61 62 -
trunk/sources/HeuristicLab.Core/3.3/Collections/ScopeList.cs
r3431 r4722 29 29 [Item("ScopeList", "Represents a list of scopes.")] 30 30 public sealed class ScopeList : ItemList<IScope> { 31 [StorableConstructor] 32 private ScopeList(bool deserializing) : base(deserializing) { } 33 private ScopeList(ScopeList original, Cloner cloner) 34 : base(original, cloner) { 35 list = new List<IScope>(original.Select(x => cloner.Clone(x))); 36 } 31 37 public ScopeList() : base() { } 32 38 public ScopeList(int capacity) : base(capacity) { } 33 39 public ScopeList(IEnumerable<IScope> collection) : base(collection) { } 34 [StorableConstructor]35 private ScopeList(bool deserializing) : base(deserializing) { }36 40 37 41 public override IDeepCloneable Clone(Cloner cloner) { 38 ScopeList clone = new ScopeList(); 39 cloner.RegisterClonedObject(this, clone); 40 clone.list = new List<IScope>(this.Select(x => (IScope)cloner.Clone(x))); 41 return clone; 42 return new ScopeList(this, cloner); 42 43 } 43 44 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/ValueParameterCollection.cs
r3390 r4722 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 27 28 [Item("ValueParameterCollection", "Represents a collection of value parameters.")] 28 29 public class ValueParameterCollection : NamedItemCollection<IValueParameter> { 30 [StorableConstructor] 31 protected ValueParameterCollection(bool deserializing) : base(deserializing) { } 32 protected ValueParameterCollection(ValueParameterCollection original, Cloner cloner) : base(original, cloner) { } 29 33 public ValueParameterCollection() : base() { } 30 34 public ValueParameterCollection(int capacity) : base(capacity) { } 31 35 public ValueParameterCollection(IEnumerable<IValueParameter> collection) : base(collection) { } 32 [StorableConstructor] 33 p rotected ValueParameterCollection(bool deserializing) : base(deserializing) {}36 37 public override IDeepCloneable Clone(Cloner cloner) { return new ValueParameterCollection(this, cloner); } 34 38 } 35 39 } -
trunk/sources/HeuristicLab.Core/3.3/Collections/VariableCollection.cs
r4068 r4722 28 28 [Item("VariableCollection", "Represents a collection of variables.")] 29 29 public sealed class VariableCollection : NamedItemCollection<IVariable> { 30 [StorableConstructor] 31 private VariableCollection(bool deserializing) : base(deserializing) { } 32 private VariableCollection(VariableCollection original, Cloner cloner) : base(original, cloner) { } 30 33 public VariableCollection() : base() { } 31 34 public VariableCollection(int capacity) : base(capacity) { } 32 35 public VariableCollection(IEnumerable<IVariable> collection) : base(collection) { } 33 [StorableConstructor]34 private VariableCollection(bool deserializing) : base(deserializing) { }35 36 36 37 public override IDeepCloneable Clone(Cloner cloner) { 37 VariableCollection clone = new VariableCollection(); 38 cloner.RegisterClonedObject(this, clone); 39 foreach (string key in dict.Keys) 40 clone.dict.Add(key, (IVariable)cloner.Clone(dict[key])); 41 clone.Initialize(); 42 return clone; 38 return new VariableCollection(this, cloner); 43 39 } 44 40 }
Note: See TracChangeset
for help on using the changeset viewer.