- Timestamp:
- 04/27/09 15:29:27 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Constraints/3.3/IntBoundedConstraint.cs
r1529 r1672 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Persistence.Default.Decomposers.Storable; 28 29 29 30 namespace HeuristicLab.Constraints { … … 32 33 /// </summary> 33 34 public class IntBoundedConstraint : ConstraintBase { 35 36 [Storable] 34 37 private int lowerBound; 35 38 /// <summary> … … 45 48 } 46 49 } 50 51 [Storable] 47 52 private bool lowerBoundIncluded; 48 53 /// <summary> … … 58 63 } 59 64 } 65 66 [Storable] 60 67 private bool lowerBoundEnabled; 61 68 /// <summary> … … 71 78 } 72 79 } 80 81 [Storable] 73 82 private int upperBound; 74 83 /// <summary> … … 84 93 } 85 94 } 95 96 [Storable] 86 97 private bool upperBoundIncluded; 87 98 /// <summary> … … 97 108 } 98 109 } 110 111 [Storable] 99 112 private bool upperBoundEnabled; 100 113 /// <summary> … … 128 141 /// <param name="low">The lower bound of the constraint.</param> 129 142 /// <param name="high">The upper bound of the constraint.</param> 130 public IntBoundedConstraint(int low, int high) : base() { 143 public IntBoundedConstraint(int low, int high) 144 : base() { 131 145 lowerBound = low; 132 146 lowerBoundIncluded = false; … … 177 191 return clone; 178 192 } 179 180 #region persistence181 /// <summary>182 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.183 /// </summary>184 /// <remarks>The properties of the current instance are saved as attributes with special tag names.</remarks>185 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>186 /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>187 /// <param name="persistedObjects">The dictionary of all already persisted objects.188 /// (Needed to avoid cycles.)</param>189 /// <returns>The saved <see cref="XmlNode"/>.</returns>190 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {191 XmlNode node = base.GetXmlNode(name, document, persistedObjects);192 XmlAttribute lb = document.CreateAttribute("LowerBound");193 lb.Value = LowerBound + "";194 XmlAttribute lbi = document.CreateAttribute("LowerBoundIncluded");195 lbi.Value = lowerBoundIncluded + "";196 XmlAttribute lbe = document.CreateAttribute("LowerBoundEnabled");197 lbe.Value = lowerBoundEnabled + "";198 XmlAttribute ub = document.CreateAttribute("UpperBound");199 ub.Value = upperBound + "";200 XmlAttribute ubi = document.CreateAttribute("UpperBoundIncluded");201 ubi.Value = upperBoundIncluded + "";202 XmlAttribute ube = document.CreateAttribute("UpperBoundEnabled");203 ube.Value = upperBoundEnabled + "";204 node.Attributes.Append(lb);205 if (!lowerBoundIncluded) node.Attributes.Append(lbi);206 if (!lowerBoundEnabled) node.Attributes.Append(lbe);207 node.Attributes.Append(ub);208 if (!upperBoundIncluded) node.Attributes.Append(ubi);209 if (!upperBoundEnabled) node.Attributes.Append(ube);210 return node;211 }212 213 /// <summary>214 /// Loads the persisted constraint from the specified <paramref name="node"/>.215 /// </summary>216 /// <remarks>The constraint must be saved in a specific way, see <see cref="GetXmlNode"/> for217 /// more information.</remarks>218 /// <param name="node">The <see cref="XmlNode"/> where the instance is saved.</param>219 /// <param name="restoredObjects">The dictionary of all already restored objects.220 /// (Needed to avoid cycles.)</param>221 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {222 base.Populate(node, restoredObjects);223 lowerBound = int.Parse(node.Attributes["LowerBound"].Value);224 if (node.Attributes["LowerBoundIncluded"] != null) {225 lowerBoundIncluded = bool.Parse(node.Attributes["LowerBoundIncluded"].Value);226 } else {227 lowerBoundIncluded = true;228 }229 if (node.Attributes["LowerBoundEnabled"] != null) {230 lowerBoundEnabled = bool.Parse(node.Attributes["LowerBoundEnabled"].Value);231 } else {232 lowerBoundEnabled = true;233 }234 235 upperBound = int.Parse(node.Attributes["UpperBound"].Value);236 if (node.Attributes["UpperBoundIncluded"] != null) {237 upperBoundIncluded = bool.Parse(node.Attributes["UpperBoundIncluded"].Value);238 } else {239 upperBoundIncluded = true;240 }241 if (node.Attributes["UpperBoundEnabled"] != null) {242 upperBoundEnabled = bool.Parse(node.Attributes["UpperBoundEnabled"].Value);243 } else {244 upperBoundEnabled = true;245 }246 }247 #endregion248 193 } 249 194 }
Note: See TracChangeset
for help on using the changeset viewer.