Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/13/10 06:41:56 (14 years ago)
Author:
swagner
Message:

Implemented ReadOnlyView property for items (#969).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Scope.cs

    r3280 r3317  
    5151    }
    5252
     53    [Storable]
    5354    private ScopeList subScopes;
    54     [Storable]
    5555    public ScopeList SubScopes {
    5656      get { return subScopes; }
    57       private set {
    58         DeregisterSubScopesEvents();
    59         subScopes = value;
    60         RegisterSubScopesEvents();
    61       }
    6257    }
    6358
     
    6964      parent = null;
    7065      variables = new VariableCollection();
    71       SubScopes = new ScopeList();
     66      subScopes = new ScopeList();
     67      Initialize();
    7268    }
    7369    /// <summary>
     
    7975      parent = null;
    8076      variables = new VariableCollection();
    81       SubScopes = new ScopeList();
     77      subScopes = new ScopeList();
     78      Initialize();
    8279    }
    8380    public Scope(string name, string description)
     
    8582      parent = null;
    8683      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();
    8893    }
    8994
     
    98103      Scope clone = new Scope();
    99104      cloner.RegisterClonedObject(this, clone);
    100       clone.Name = Name;
    101       clone.Description = Description;
     105      clone.ReadOnlyView = ReadOnlyView;
     106      clone.name = name;
     107      clone.description = description;
    102108      if (variables.Count > 0) clone.variables = (VariableCollection)cloner.Clone(variables);
    103109      if (subScopes.Count > 0) {
    104         clone.SubScopes = (ScopeList)cloner.Clone(subScopes);
     110        clone.subScopes = (ScopeList)cloner.Clone(subScopes);
    105111        foreach (IScope child in clone.SubScopes)
    106112          child.Parent = clone;
     113        clone.Initialize();
    107114      }
    108115      return clone;
     
    116123        subScopes.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);
    117124        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);
    126125      }
    127126    }
Note: See TracChangeset for help on using the changeset viewer.