Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4762


Ignore:
Timestamp:
11/10/10 13:39:14 (14 years ago)
Author:
epitzer
Message:

Correct cloning of ProgrammableOperator and ensure static initialization in storable constructor (#922)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs

    r4722 r4762  
    7575
    7676    public readonly Dictionary<string, List<Assembly>> Plugins;
    77 
    7877    protected Dictionary<Assembly, bool> Assemblies;
    7978
     
    160159
    161160    #region Construction & Initialization
     161
    162162    [StorableConstructor]
    163     protected ProgrammableOperator(bool deserializing) : base(deserializing) { }
    164     [StorableHook(HookType.AfterDeserialization)]
    165     private void AfterDeserialization() {
    166       RegisterEvents();
     163    protected ProgrammableOperator(bool deserializing)
     164      : base(deserializing) {
     165      ProgrammableOperator.StaticInitialize();
     166      Assemblies = defaultAssemblyDict.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
     167      Plugins = defaultPluginDict.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToList());
    167168    }
    168169
     
    172173      executeMethod = original.executeMethod;
    173174      Assemblies = original.Assemblies.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
    174       namespaces = original.namespaces;
     175      Plugins = original.Plugins.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
     176      namespaces = new HashSet<string>(original.namespaces);
    175177      CompilationUnitCode = original.CompilationUnitCode;
    176       CompileErrors = original.CompileErrors;
     178      CompileErrors = new CompilerErrorCollection(original.CompileErrors);
    177179      RegisterEvents();
    178     }
    179     public override IDeepCloneable Clone(Cloner cloner) {
    180       return new ProgrammableOperator(this, cloner);
    181180    }
    182181
     
    191190    }
    192191
     192    [StorableHook(HookType.AfterDeserialization)]
     193    private void AfterDeserialization() {
     194      RegisterEvents();
     195    }
     196
     197    public override IDeepCloneable Clone(Cloner cloner) {
     198      return new ProgrammableOperator(this, cloner);
     199    }
    193200
    194201    private void RegisterEvents() {
     
    261268            assemblies.Add(a, false);
    262269          }
    263         }
    264         catch (NotSupportedException) {
     270        } catch (NotSupportedException) {
    265271          // NotSupportedException is thrown while accessing
    266272          // the Location property of the anonymously hosted
Note: See TracChangeset for help on using the changeset viewer.