- Timestamp:
- 04/27/09 15:29:27 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Constraints/3.3/DoubleBoundedConstraint.cs
r1529 r1672 27 27 using HeuristicLab.Data; 28 28 using System.Globalization; 29 using HeuristicLab.Persistence.Default.Decomposers.Storable; 29 30 30 31 namespace HeuristicLab.Constraints { … … 33 34 /// </summary> 34 35 public class DoubleBoundedConstraint : ConstraintBase { 36 37 [Storable] 35 38 private double lowerBound; 36 39 /// <summary> … … 46 49 } 47 50 } 51 52 [Storable] 48 53 private bool lowerBoundIncluded; 49 54 /// <summary> … … 59 64 } 60 65 } 66 67 [Storable] 61 68 private bool lowerBoundEnabled; 62 69 /// <summary> … … 72 79 } 73 80 } 81 82 [Storable] 74 83 private double upperBound; 75 84 /// <summary> … … 85 94 } 86 95 } 96 97 [Storable] 87 98 private bool upperBoundIncluded; 88 99 /// <summary> … … 98 109 } 99 110 } 111 112 [Storable] 100 113 private bool upperBoundEnabled; 101 114 /// <summary> … … 191 204 return clone; 192 205 } 193 194 #region persistence195 /// <summary>196 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.197 /// </summary>198 /// <remarks>The properties of the current instance are saved as attributes with special tag names.</remarks>199 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>200 /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>201 /// <param name="persistedObjects">The dictionary of all already persisted objects.202 /// (Needed to avoid cycles.)</param>203 /// <returns>The saved <see cref="XmlNode"/>.</returns>204 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {205 XmlNode node = base.GetXmlNode(name, document, persistedObjects);206 XmlAttribute lb = document.CreateAttribute("LowerBound");207 lb.Value = LowerBound.ToString("r", CultureInfo.InvariantCulture);208 XmlAttribute lbi = document.CreateAttribute("LowerBoundIncluded");209 lbi.Value = lowerBoundIncluded.ToString();210 XmlAttribute lbe = document.CreateAttribute("LowerBoundEnabled");211 lbe.Value = lowerBoundEnabled.ToString();212 XmlAttribute ub = document.CreateAttribute("UpperBound");213 ub.Value = upperBound.ToString("r", CultureInfo.InvariantCulture);214 XmlAttribute ubi = document.CreateAttribute("UpperBoundIncluded");215 ubi.Value = upperBoundIncluded.ToString();216 XmlAttribute ube = document.CreateAttribute("UpperBoundEnabled");217 ube.Value = upperBoundEnabled.ToString();218 node.Attributes.Append(lb);219 if (!lowerBoundIncluded) node.Attributes.Append(lbi);220 if (!lowerBoundEnabled) node.Attributes.Append(lbe);221 node.Attributes.Append(ub);222 if (!upperBoundIncluded) node.Attributes.Append(ubi);223 if (!upperBoundEnabled) node.Attributes.Append(ube);224 return node;225 }226 227 /// <summary>228 /// Loads the persisted constraint from the specified <paramref name="node"/>.229 /// </summary>230 /// <remarks>The constraint must be saved in a specific way, see <see cref="GetXmlNode"/> for231 /// more information.</remarks>232 /// <param name="node">The <see cref="XmlNode"/> where the instance is saved.</param>233 /// <param name="restoredObjects">The dictionary of all already restored objects.234 /// (Needed to avoid cycles.)</param>235 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {236 base.Populate(node, restoredObjects);237 lowerBound = double.Parse(node.Attributes["LowerBound"].Value, CultureInfo.InvariantCulture);238 if (node.Attributes["LowerBoundIncluded"] != null) {239 lowerBoundIncluded = bool.Parse(node.Attributes["LowerBoundIncluded"].Value);240 } else {241 lowerBoundIncluded = true;242 }243 if (node.Attributes["LowerBoundEnabled"] != null) {244 lowerBoundEnabled = bool.Parse(node.Attributes["LowerBoundEnabled"].Value);245 } else {246 lowerBoundEnabled = true;247 }248 249 upperBound = double.Parse(node.Attributes["UpperBound"].Value, CultureInfo.InvariantCulture);250 if (node.Attributes["UpperBoundIncluded"] != null) {251 upperBoundIncluded = bool.Parse(node.Attributes["UpperBoundIncluded"].Value);252 } else {253 upperBoundIncluded = true;254 }255 if (node.Attributes["UpperBoundEnabled"] != null) {256 upperBoundEnabled = bool.Parse(node.Attributes["UpperBoundEnabled"].Value);257 } else {258 upperBoundEnabled = true;259 }260 }261 #endregion262 206 } 263 207 }
Note: See TracChangeset
for help on using the changeset viewer.