Changeset 7431 for trunk/sources/HeuristicLab.Optimization
- Timestamp:
- 01/31/12 13:09:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/Problems/Problem.cs
r7259 r7431 44 44 45 45 [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) { } 50 47 protected Problem(Problem original, Cloner cloner) 51 48 : base(original, cloner) { 52 operators = cloner.Clone(original.operators);53 49 RegisterEventHandlers(); 54 50 } … … 56 52 protected Problem() 57 53 : 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)); 60 55 OperatorsParameter.Hidden = true; 61 56 RegisterEventHandlers(); … … 64 59 [StorableHook(HookType.AfterDeserialization)] 65 60 private void AfterDeserialization() { 66 // BackwardsCompatibility3.367 #region Backwards compatible code, remove with 3.468 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 #endregion73 61 RegisterEventHandlers(); 74 62 } … … 81 69 82 70 #region properties 83 private OperatorCollection operators; 71 // BackwardsCompatibility3.3 72 #region Backwards compatible code, remove with 3.4 84 73 [Storable(Name = "Operators")] 85 74 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 } 88 82 } 83 #endregion 89 84 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 } 91 95 } 92 IEnumerable<IOperator> IProblem.Operators { get { return operators; } }96 IEnumerable<IOperator> IProblem.Operators { get { return Operators; } } 93 97 #endregion 94 98
Note: See TracChangeset
for help on using the changeset viewer.