- Timestamp:
- 04/27/09 15:29:27 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Constraints/3.3/OrConstraint.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 OrConstraint : ConstraintBase, IViewable { 35 36 [Storable] 34 37 private ItemList<IConstraint> clauses; 35 38 /// <summary> … … 67 70 public override bool Check(IItem data) { 68 71 bool result = false; 69 for (int i = 0 ; i < clauses.Count; i++) {72 for (int i = 0; i < clauses.Count; i++) { 70 73 result = clauses[i].Check(data); 71 74 if (result) return true; … … 96 99 return clone; 97 100 } 98 99 #region persistence100 /// <summary>101 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.102 /// </summary>103 /// <remarks>The sub-constraints are saved as a child node with tag name104 /// <c>Clauses</c>.</remarks>105 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>106 /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>107 /// <param name="persistedObjects">The dictionary of all already persisted objects.108 /// (Needed to avoid cycles.)</param>109 /// <returns>The saved <see cref="XmlNode"/>.</returns>110 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {111 XmlNode node = base.GetXmlNode(name, document, persistedObjects);112 XmlNode clausesNode = PersistenceManager.Persist("Clauses", Clauses, document, persistedObjects);113 node.AppendChild(clausesNode);114 115 return node;116 }117 118 /// <summary>119 /// Loads the persisted constraint from the specified <paramref name="node"/>.120 /// </summary>121 /// <remarks>The constraint must be saved in a specific way, see <see cref="GetXmlNode"/> for122 /// more information.</remarks>123 /// <param name="node">The <see cref="XmlNode"/> where the instance is saved.</param>124 /// <param name="restoredObjects">The dictionary of all already restored objects.125 /// (Needed to avoid cycles.)</param>126 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {127 base.Populate(node, restoredObjects);128 clauses = (ItemList<IConstraint>)PersistenceManager.Restore(node.SelectSingleNode("Clauses"), restoredObjects);129 }130 #endregion persistence131 101 } 132 102 }
Note: See TracChangeset
for help on using the changeset viewer.