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/VariableComparisonConstraint.cs

    r1529 r1672  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Persistence.Default.Decomposers.Storable;
    2829
    2930namespace HeuristicLab.Constraints {
     
    3233  /// </summary>
    3334  public class VariableComparisonConstraint : ConstraintBase {
     35
     36    [Storable]
    3437    private StringData leftVarName;
    3538    /// <summary>
     
    4144    }
    4245
     46    [Storable]
    4347    private StringData rightVarName;
    4448    /// <summary>
     
    5054    }
    5155
     56    [Storable]
    5257    private IntData comparer;
    5358    /// <summary>
     
    125130    }
    126131
    127     #region clone & persistence
    128132    /// <summary>
    129133    /// Clones the current instance (deep clone).
     
    141145      return clone;
    142146    }
    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 names
    148     /// <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"/> for
    169     /// 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     #endregion
    180147  }
    181148}
Note: See TracChangeset for help on using the changeset viewer.