- Timestamp:
- 04/27/09 15:29:27 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Constraints/3.3/ItemTypeConstraint.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 { … … 34 35 /// the type and not the <see cref="ConstrainedItemList"/> itself.</remarks> 35 36 public class ItemTypeConstraint : ConstraintBase { 37 38 [Storable] 36 39 private Type type; 37 40 /// <summary> … … 96 99 } 97 100 98 #region clone & persistence99 101 /// <summary> 100 102 /// Clones the current instance (deep clone). … … 107 109 return clone; 108 110 } 109 110 /// <summary>111 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.112 /// </summary>113 /// <remarks>The type of the current instance is saved as attribute with tag name <c>ItemType</c>.</remarks>114 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>115 /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>116 /// <param name="persistedObjects">The dictionary of all already persisted objects.117 /// (Needed to avoid cycles.)</param>118 /// <returns>The saved <see cref="XmlNode"/>.</returns>119 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {120 XmlNode node = base.GetXmlNode(name, document, persistedObjects);121 XmlAttribute itemTypeAttribute = document.CreateAttribute("ItemType");122 itemTypeAttribute.Value = PersistenceManager.BuildTypeString(Type);123 node.Attributes.Append(itemTypeAttribute);124 return node;125 }126 127 /// <summary>128 /// Loads the persisted constraint from the specified <paramref name="node"/>.129 /// </summary>130 /// <remarks>The constraint must be saved in a specific way, see <see cref="GetXmlNode"/> for131 /// more information.</remarks>132 /// <param name="node">The <see cref="XmlNode"/> where the instance is saved.</param>133 /// <param name="restoredObjects">The dictionary of all already restored objects.134 /// (Needed to avoid cycles.)</param>135 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {136 base.Populate(node, restoredObjects);137 XmlAttribute itemTypeAttribute = node.Attributes["ItemType"];138 type = Type.GetType(itemTypeAttribute.Value);139 }140 #endregion141 111 } 142 112 }
Note: See TracChangeset
for help on using the changeset viewer.