Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/10 17:38:42 (14 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/Scope.cs

    r4489 r4668  
    5959    }
    6060
     61    [StorableConstructor]
     62    private Scope(bool deserializing) : base(deserializing) { }
     63    private Scope(Scope original, Cloner cloner)
     64      : base(original, cloner) {
     65      if (original.variables.Count > 0) variables = cloner.Clone(original.variables);
     66      if (original.subScopes.Count > 0) {
     67        subScopes = cloner.Clone(original.subScopes);
     68        foreach (IScope child in SubScopes)
     69          child.Parent = this;
     70        RegisterSubScopesEvents();
     71      }
     72    }
    6173    /// <summary>
    6274    /// Initializes a new instance of <see cref="Scope"/> having "Anonymous" as default name.
     
    6779      variables = new VariableCollection();
    6880      subScopes = new ScopeList();
    69       Initialize();
     81      RegisterSubScopesEvents();
    7082    }
    7183    /// <summary>
     
    7890      variables = new VariableCollection();
    7991      subScopes = new ScopeList();
    80       Initialize();
     92      RegisterSubScopesEvents();
    8193    }
    8294    public Scope(string name, string description)
     
    8597      variables = new VariableCollection();
    8698      subScopes = new ScopeList();
    87       Initialize();
     99      RegisterSubScopesEvents();
    88100    }
    89     [StorableConstructor]
    90     private Scope(bool deserializing) : base(deserializing) { }
    91101
    92102    [StorableHook(HookType.AfterDeserialization)]
    93     private void Initialize() {
     103    private void AfterDeserialization() {
    94104      RegisterSubScopesEvents();
    95105    }
     
    103113    /// <inheritdoc/>
    104114    public override IDeepCloneable Clone(Cloner cloner) {
    105       Scope clone = new Scope();
    106       cloner.RegisterClonedObject(this, clone);
    107       clone.name = name;
    108       clone.description = description;
    109       if (variables.Count > 0) clone.variables = (VariableCollection)cloner.Clone(variables);
    110       if (subScopes.Count > 0) {
    111         clone.subScopes = (ScopeList)cloner.Clone(subScopes);
    112         foreach (IScope child in clone.SubScopes)
    113           child.Parent = clone;
    114         clone.Initialize();
    115       }
    116       return clone;
     115      return new Scope(this, cloner);
    117116    }
    118117
Note: See TracChangeset for help on using the changeset viewer.