Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators/3.3/CombinedOperator.cs

    r1530 r1673  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Persistence.Default.Decomposers.Storable;
    2829
    2930namespace HeuristicLab.Operators {
     
    3334  /// </summary>
    3435  public class CombinedOperator : DelegatingOperator {
     36
     37    [Storable]
    3538    private string myDescription;
    3639    /// <summary>
     
    4043      get { return myDescription; }
    4144    }
     45
     46    [Storable]
    4247    private IOperatorGraph myOperatorGraph;
    4348    /// <summary>
     
    131136        DescriptionChanged(this, new EventArgs());
    132137    }
    133 
    134     #region Persistence Methods
    135     /// <summary>
    136     /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
    137     /// </summary>
    138     /// <remarks>The description and the operator graph of the current instance are saved as child
    139     /// nodes with tag names <c>Description</c> <c>OperatorGraph</c>.<br/>
    140     /// Calls <see cref="OperatorBase.GetXmlNode"/> of base class <see cref="DelegatingOperator"/>.</remarks>
    141     /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
    142     /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
    143     /// <param name="persistedObjects">The dictionary of all already persisted objects. (Needed to avoid cycles.)</param>
    144     /// <returns>The saved <see cref="XmlNode"/>.</returns>
    145     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    146       XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    147       XmlNode descriptionNode = document.CreateNode(XmlNodeType.Element, "Description", null);
    148       descriptionNode.InnerText = myDescription;
    149       node.AppendChild(descriptionNode);
    150       node.AppendChild(PersistenceManager.Persist("OperatorGraph", OperatorGraph, document, persistedObjects));
    151       return node;
    152     }
    153     /// <summary>
    154     /// Loads the persisted instance from the specified <paramref name="node"/>.
    155     /// </summary>
    156     /// <remarks>Calls <see cref="OperatorBase.Populate"/> of base class <see cref="DelegatingOperator"/>.
    157     /// <br/> See <see cref="GetXmlNode"/> for further information on how the data must be saved.</remarks>
    158     /// <param name="node">The <see cref="XmlNode"/> where the operator is saved.</param>
    159     /// <param name="restoredObjects">The dictionary of all already restored objects.
    160     /// (Needed to avoid cycles.)</param>
    161     public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
    162       base.Populate(node, restoredObjects);
    163       XmlNode descriptionNode = node.SelectSingleNode("Description");
    164       if (descriptionNode != null) myDescription = descriptionNode.InnerText;
    165       myOperatorGraph = (IOperatorGraph)PersistenceManager.Restore(node.SelectSingleNode("OperatorGraph"), restoredObjects);
    166     }
    167     #endregion
    168138  }
    169139}
Note: See TracChangeset for help on using the changeset viewer.