Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/10 17:38:42 (13 years ago)
Author:
swagner
Message:

Finished cloning refactoring of HeuristicLab.Common, HeuristicLab.Collections and HeuristicLab.Core (#922)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CloningRefactoring/HeuristicLab.Core/3.3/Variable.cs

    r4477 r4668  
    5555    }
    5656
     57    [StorableConstructor]
     58    private Variable(bool deserializing) : base(deserializing) { }
     59    private Variable(Variable original, Cloner cloner)
     60      : base(original, cloner) {
     61      value = cloner.Clone(original.value);
     62      RegisterValueEvents();
     63    }
    5764    /// <summary>
    5865    /// Initializes a new instance of <see cref="Variable"/> with name <c>Anonymous</c>
     
    8087      : base(name) {
    8188      this.value = value;
    82       Initialize();
     89      RegisterValueEvents();
    8390    }
    8491    public Variable(string name, string description, IItem value)
    8592      : base(name, description) {
    8693      this.value = value;
    87       Initialize();
     94      RegisterValueEvents();
    8895    }
    89     [StorableConstructor]
    90     private Variable(bool deserializing) : base(deserializing) { }
    9196
    9297    [StorableHook(HookType.AfterDeserialization)]
    93     private void Initialize() {
     98    private void AfterDeserialization() {
    9499      RegisterValueEvents();
    95100    }
     
    101106    /// <returns>The cloned object as <see cref="Variable"/>.</returns>
    102107    public override IDeepCloneable Clone(Cloner cloner) {
    103       Variable clone = new Variable(Name, Description);
    104       cloner.RegisterClonedObject(this, clone);
    105       clone.value = (IItem)cloner.Clone(value);
    106       clone.Initialize();
    107       return clone;
     108      return new Variable(this, cloner);
    108109    }
    109110
     
    125126    /// </summary>
    126127    private void OnValueChanged() {
    127       if (ValueChanged != null)
    128         ValueChanged(this, EventArgs.Empty);
     128      var handler = ValueChanged;
     129      if (handler != null) handler(this, EventArgs.Empty);
    129130      OnItemImageChanged();
    130131      OnToStringChanged();
Note: See TracChangeset for help on using the changeset viewer.