Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/27/09 15:29:27 (15 years ago)
Author:
epitzer
Message:

Migrate HL.Constraints-3.3 to new persistence library. (#603)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Constraints/3.3/ItemTypeConstraint.cs

    r1529 r1672  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Persistence.Default.Decomposers.Storable;
    2829
    2930namespace HeuristicLab.Constraints {
     
    3435  /// the type and not the <see cref="ConstrainedItemList"/> itself.</remarks>
    3536  public class ItemTypeConstraint : ConstraintBase {
     37
     38    [Storable]
    3639    private Type type;
    3740    /// <summary>
     
    9699    }
    97100
    98     #region clone & persistence
    99101    /// <summary>
    100102    /// Clones the current instance (deep clone).
     
    107109      return clone;
    108110    }
    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"/> for
    131     /// 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     #endregion
    141111  }
    142112}
Note: See TracChangeset for help on using the changeset viewer.