Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7431


Ignore:
Timestamp:
01/31/12 13:09:08 (13 years ago)
Author:
abeham
Message:

#1769

  • removed private field and stored the collection in the parameter only
  • forwarded calls to Operators to the parameter
  • put StorableOperators property out of use as the collection is persisted through the parameters' persistence
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r7259 r7431  
    4444
    4545    [StorableConstructor]
    46     protected Problem(bool deserializing)
    47       : base(deserializing) {
    48       operators = new OperatorCollection(); // operators must never be null
    49     }
     46    protected Problem(bool deserializing) : base(deserializing) { }
    5047    protected Problem(Problem original, Cloner cloner)
    5148      : base(original, cloner) {
    52       operators = cloner.Clone(original.operators);
    5349      RegisterEventHandlers();
    5450    }
     
    5652    protected Problem()
    5753      : base() {
    58       operators = new OperatorCollection();
    59       Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", operators, false));
     54      Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(), false));
    6055      OperatorsParameter.Hidden = true;
    6156      RegisterEventHandlers();
     
    6459    [StorableHook(HookType.AfterDeserialization)]
    6560    private void AfterDeserialization() {
    66       // BackwardsCompatibility3.3
    67       #region Backwards compatible code, remove with 3.4
    68       if (!Parameters.ContainsKey(OperatorsParameterName)) {
    69         Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", operators, false));
    70         OperatorsParameter.Hidden = true;
    71       }
    72       #endregion
    7361      RegisterEventHandlers();
    7462    }
     
    8169
    8270    #region properties
    83     private OperatorCollection operators;
     71    // BackwardsCompatibility3.3
     72    #region Backwards compatible code, remove with 3.4
    8473    [Storable(Name = "Operators")]
    8574    private IEnumerable<IOperator> StorableOperators {
    86       get { return operators; }
    87       set { operators = new OperatorCollection(value); }
     75      get { return null; }
     76      set {
     77        if (!Parameters.ContainsKey(OperatorsParameterName)) {
     78          Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(value), false));
     79          OperatorsParameter.Hidden = true;
     80        }
     81      }
    8882    }
     83    #endregion
    8984    protected OperatorCollection Operators {
    90       get { return this.operators; }
     85      get {
     86        // BackwardsCompatibility3.3
     87        #region Backwards compatible code, remove with 3.4
     88        if (!Parameters.ContainsKey(OperatorsParameterName)) {
     89          Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(), false));
     90          OperatorsParameter.Hidden = true;
     91        }
     92        #endregion
     93        return OperatorsParameter.Value;
     94      }
    9195    }
    92     IEnumerable<IOperator> IProblem.Operators { get { return operators; } }
     96    IEnumerable<IOperator> IProblem.Operators { get { return Operators; } }
    9397    #endregion
    9498
Note: See TracChangeset for help on using the changeset viewer.