- Timestamp:
- 04/27/09 15:29:27 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Constraints/3.3/VariableComparisonConstraint.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 VariableComparisonConstraint : ConstraintBase { 35 36 [Storable] 34 37 private StringData leftVarName; 35 38 /// <summary> … … 41 44 } 42 45 46 [Storable] 43 47 private StringData rightVarName; 44 48 /// <summary> … … 50 54 } 51 55 56 [Storable] 52 57 private IntData comparer; 53 58 /// <summary> … … 125 130 } 126 131 127 #region clone & persistence128 132 /// <summary> 129 133 /// Clones the current instance (deep clone). … … 141 145 return clone; 142 146 } 143 144 /// <summary>145 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.146 /// </summary>147 /// <remarks>The variable names and the comparer are saved as child nodes with tag names148 /// <c>LeftVarName</c>, <c>RightVarName</c> and <c>Comparer</c>.</remarks>149 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>150 /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>151 /// <param name="persistedObjects">The dictionary of all already persisted objects.152 /// (Needed to avoid cycles.)</param>153 /// <returns>The saved <see cref="XmlNode"/>.</returns>154 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {155 XmlNode node = base.GetXmlNode(name, document, persistedObjects);156 XmlNode leftNode = PersistenceManager.Persist("LeftVarName", LeftVarName, document, persistedObjects);157 node.AppendChild(leftNode);158 XmlNode rightNode = PersistenceManager.Persist("RightVarName", RightVarName, document, persistedObjects);159 node.AppendChild(rightNode);160 XmlNode comparerNode = PersistenceManager.Persist("Comparer", Comparer, document, persistedObjects);161 node.AppendChild(comparerNode);162 return node;163 }164 165 /// <summary>166 /// Loads the persisted constraint from the specified <paramref name="node"/>.167 /// </summary>168 /// <remarks>The constraint must be saved in a specific way, see <see cref="GetXmlNode"/> for169 /// more information.</remarks>170 /// <param name="node">The <see cref="XmlNode"/> where the instance is saved.</param>171 /// <param name="restoredObjects">The dictionary of all already restored objects.172 /// (Needed to avoid cycles.)</param>173 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {174 base.Populate(node, restoredObjects);175 leftVarName = (StringData)PersistenceManager.Restore(node.SelectSingleNode("LeftVarName"), restoredObjects);176 rightVarName = (StringData)PersistenceManager.Restore(node.SelectSingleNode("RightVarName"), restoredObjects);177 comparer = (IntData)PersistenceManager.Restore(node.SelectSingleNode("Comparer"), restoredObjects);178 }179 #endregion180 147 } 181 148 }
Note: See TracChangeset
for help on using the changeset viewer.