- Timestamp:
- 04/27/09 15:29:27 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Constraints/3.3/NumberOfSubOperatorsConstraint.cs
r1529 r1672 27 27 using HeuristicLab.Data; 28 28 using System.Xml; 29 using HeuristicLab.Persistence.Default.Decomposers.Storable; 29 30 30 31 namespace HeuristicLab.Constraints { … … 33 34 /// </summary> 34 35 public class NumberOfSubOperatorsConstraint : ConstraintBase { 36 37 [Storable] 35 38 private IntData minOperators; 39 40 [Storable] 36 41 private IntData maxOperators; 37 42 … … 59 64 /// </summary> 60 65 public NumberOfSubOperatorsConstraint() 61 : this(0, 0) {66 : this(0, 0) { 62 67 } 63 68 … … 68 73 /// <param name="min">The minimum number of sub-operators.</param> 69 74 /// <param name="max">The maximum number of sub-operators.</param> 70 public NumberOfSubOperatorsConstraint(int min, int max) : base() { 75 public NumberOfSubOperatorsConstraint(int min, int max) 76 : base() { 71 77 minOperators = new IntData(min); 72 78 maxOperators = new IntData(max); … … 106 112 return new NumberOfSubOperatorsConstraintView(this); 107 113 } 108 109 #region persistence110 /// <summary>111 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.112 /// </summary>113 /// <remarks>The minimum and the maximum number of sub-operators are saved as child nodes with tag114 /// names <c>min</c> and <c>max</c>.</remarks>115 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>116 /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>117 /// <param name="persistedObjects">The dictionary of all already persisted objects.118 /// (Needed to avoid cycles.)</param>119 /// <returns>The saved <see cref="XmlNode"/>.</returns>120 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {121 XmlNode node = base.GetXmlNode(name, document, persistedObjects);122 XmlNode minNode = PersistenceManager.Persist("min", minOperators, document, persistedObjects);123 XmlNode maxNode = PersistenceManager.Persist("max", maxOperators, document, persistedObjects);124 node.AppendChild(minNode);125 node.AppendChild(maxNode);126 return node;127 }128 129 /// <summary>130 /// Loads the persisted constraint from the specified <paramref name="node"/>.131 /// </summary>132 /// <remarks>The constraint must be saved in a specific way, see <see cref="GetXmlNode"/> for133 /// more information.</remarks>134 /// <param name="node">The <see cref="XmlNode"/> where the instance is saved.</param>135 /// <param name="restoredObjects">The dictionary of all already restored objects.136 /// (Needed to avoid cycles.)</param>137 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {138 base.Populate(node, restoredObjects);139 minOperators = (IntData)PersistenceManager.Restore(node.SelectSingleNode("min"), restoredObjects);140 maxOperators = (IntData)PersistenceManager.Restore(node.SelectSingleNode("max"), restoredObjects);141 }142 #endregion persistence143 144 114 } 145 115 }
Note: See TracChangeset
for help on using the changeset viewer.