Free cookie consent management tool by TermsFeed Policy Generator

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

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs

    r4477 r4722  
    160160
    161161    #region Construction & Initialization
     162    [StorableConstructor]
     163    protected ProgrammableOperator(bool deserializing) : base(deserializing) { }
     164    [StorableHook(HookType.AfterDeserialization)]
     165    private void AfterDeserialization() {
     166      RegisterEvents();
     167    }
     168
     169    protected ProgrammableOperator(ProgrammableOperator original, Cloner cloner)
     170      : base(original, cloner) {
     171      code = original.Code;
     172      executeMethod = original.executeMethod;
     173      Assemblies = original.Assemblies.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
     174      namespaces = original.namespaces;
     175      CompilationUnitCode = original.CompilationUnitCode;
     176      CompileErrors = original.CompileErrors;
     177      RegisterEvents();
     178    }
     179    public override IDeepCloneable Clone(Cloner cloner) {
     180      return new ProgrammableOperator(this, cloner);
     181    }
    162182
    163183    public ProgrammableOperator() {
     
    171191    }
    172192
    173     [StorableHook(HookType.AfterDeserialization)]
     193
    174194    private void RegisterEvents() {
    175195      Parameters.ItemsAdded += Parameters_Changed;
     
    185205    protected void OnSignatureChanged() {
    186206      EventHandler handler = SignatureChanged;
    187       if (handler != null)
    188         handler(this, EventArgs.Empty);
     207      if (handler != null) handler(this, EventArgs.Empty);
    189208    }
    190209
     
    426445    public event EventHandler CodeChanged;
    427446    protected virtual void OnCodeChanged() {
    428       if (CodeChanged != null)
    429         CodeChanged(this, new EventArgs());
     447      EventHandler handler = CodeChanged;
     448      if (handler != null) handler(this, EventArgs.Empty);
    430449    }
    431450
    432451    #endregion
    433 
    434     #region Cloning
    435 
    436     public override IDeepCloneable Clone(Cloner cloner) {
    437       ProgrammableOperator clone = (ProgrammableOperator)base.Clone(cloner);
    438       clone.code = Code;
    439       clone.executeMethod = executeMethod;
    440       clone.Assemblies = Assemblies.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
    441       clone.namespaces = namespaces;
    442       clone.CompilationUnitCode = CompilationUnitCode;
    443       clone.CompileErrors = CompileErrors;
    444       clone.RegisterEvents();
    445       return clone;
    446     }
    447 
    448     #endregion
    449 
    450452  }
    451453}
Note: See TracChangeset for help on using the changeset viewer.