Changeset 3317 for trunk/sources/HeuristicLab.Core/3.3/Scope.cs
- Timestamp:
- 04/13/10 06:41:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Scope.cs
r3280 r3317 51 51 } 52 52 53 [Storable] 53 54 private ScopeList subScopes; 54 [Storable]55 55 public ScopeList SubScopes { 56 56 get { return subScopes; } 57 private set {58 DeregisterSubScopesEvents();59 subScopes = value;60 RegisterSubScopesEvents();61 }62 57 } 63 58 … … 69 64 parent = null; 70 65 variables = new VariableCollection(); 71 SubScopes = new ScopeList(); 66 subScopes = new ScopeList(); 67 Initialize(); 72 68 } 73 69 /// <summary> … … 79 75 parent = null; 80 76 variables = new VariableCollection(); 81 SubScopes = new ScopeList(); 77 subScopes = new ScopeList(); 78 Initialize(); 82 79 } 83 80 public Scope(string name, string description) … … 85 82 parent = null; 86 83 variables = new VariableCollection(); 87 SubScopes = new ScopeList(); 84 subScopes = new ScopeList(); 85 Initialize(); 86 } 87 [StorableConstructor] 88 private Scope(bool deserializing) : base(deserializing) { } 89 90 [StorableHook(HookType.AfterDeserialization)] 91 private void Initialize() { 92 RegisterSubScopesEvents(); 88 93 } 89 94 … … 98 103 Scope clone = new Scope(); 99 104 cloner.RegisterClonedObject(this, clone); 100 clone.Name = Name; 101 clone.Description = Description; 105 clone.ReadOnlyView = ReadOnlyView; 106 clone.name = name; 107 clone.description = description; 102 108 if (variables.Count > 0) clone.variables = (VariableCollection)cloner.Clone(variables); 103 109 if (subScopes.Count > 0) { 104 clone. SubScopes = (ScopeList)cloner.Clone(subScopes);110 clone.subScopes = (ScopeList)cloner.Clone(subScopes); 105 111 foreach (IScope child in clone.SubScopes) 106 112 child.Parent = clone; 113 clone.Initialize(); 107 114 } 108 115 return clone; … … 116 123 subScopes.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced); 117 124 subScopes.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset); 118 }119 }120 private void DeregisterSubScopesEvents() {121 if (subScopes != null) {122 subScopes.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsAdded);123 subScopes.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsRemoved);124 subScopes.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);125 subScopes.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);126 125 } 127 126 }
Note: See TracChangeset
for help on using the changeset viewer.