Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/27/09 14:18:39 (15 years ago)
Author:
epitzer
Message:

Convert persistence of Core plugin to new persistence framework. The target framework has been upgraded from 2.0 to 3.5 and events during persistence are not generated anymore. (#603)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/OperatorGroup.cs

    r1529 r1667  
    2424using System.Text;
    2525using System.Xml;
     26using HeuristicLab.Persistence.Default.Decomposers.Storable;
    2627
    2728namespace HeuristicLab.Core {
     
    3031  /// </summary>
    3132  public class OperatorGroup : StorableBase, IOperatorGroup {
     33
     34    [Storable]
    3235    private string myName;
    3336    /// <summary>
     
    4447      }
    4548    }
     49
     50    [Storable]
    4651    private List<IOperatorGroup> mySubGroups;
    4752    /// <summary>
     
    5257      get { return mySubGroups.AsReadOnly(); }
    5358    }
     59
     60    [Storable]
    5461    private List<IOperator> myOperators;
    5562    /// <summary>
     
    128135      }
    129136    }
    130 
    131     #region Persistence Methods
    132     /// <summary>
    133     /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
    134     /// </summary>
    135     /// <remarks>Calls <see cref="StorableBase.GetXmlNode"/> of base class <see cref="ItemBase"/>.<br/>
    136     /// A quick overview how the single elements of the current instance are saved:
    137     /// <list type="bullet">
    138     /// <item>
    139     /// <term>Name: </term>
    140     /// <description>Saved as an <see cref="XmlAttribute"/> with attribute name <c>Name</c>.</description>
    141     /// </item>
    142     /// <item>
    143     /// <term>Sub groups: </term>
    144     /// <description>A child node is created with tag name <c>SubGroups</c>. Beyond this child node
    145     /// all sub operator groups are saved as child nodes themselves.</description>
    146     /// </item>
    147     /// <item>
    148     /// <term>Operators: </term>
    149     /// <description>A child node is created with tag name <c>Operators</c>. Beyond this child node
    150     /// all operators are saved as child nodes themselves.</description>
    151     /// </item>
    152     /// </list>
    153     /// </remarks>
    154     /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
    155     /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
    156     /// <param name="persistedObjects">The dictionary of all already persisted objects. (Needed to avoid cycles.)</param>
    157     /// <returns>The saved <see cref="XmlNode"/>.</returns>
    158     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    159       XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    160       XmlAttribute nameAttribute = document.CreateAttribute("Name");
    161       nameAttribute.Value = Name;
    162       node.Attributes.Append(nameAttribute);
    163       XmlNode subGroupsNode = document.CreateNode(XmlNodeType.Element, "SubGroups", null);
    164       foreach (IOperatorGroup group in SubGroups)
    165         subGroupsNode.AppendChild(PersistenceManager.Persist(group, document, persistedObjects));
    166       node.AppendChild(subGroupsNode);
    167       XmlNode operatorsNode = document.CreateNode(XmlNodeType.Element, "Operators", null);
    168       foreach (IOperator op in Operators)
    169         operatorsNode.AppendChild(PersistenceManager.Persist(op, document, persistedObjects));
    170       node.AppendChild(operatorsNode);
    171       return node;
    172     }
    173     /// <summary>
    174     /// Loads the persisted operator group from the specified <paramref name="node"/>.
    175     /// </summary>
    176     /// <remarks>See <see cref="GetXmlNode"/> to get information about how the data must be saved. <br/>
    177     /// Calls <see cref="StorableBase.Populate"/> of base class <see cref="StorableBase"/>.</remarks>
    178     /// <param name="node">The <see cref="XmlNode"/> where the boolean value is saved.</param>
    179     /// <param name="restoredObjects">The dictionary of all already restored objects.
    180     /// (Needed to avoid cycles.)</param>
    181     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    182       base.Populate(node, restoredObjects);
    183       myName = node.Attributes["Name"].Value;
    184       XmlNode subGroupsNode = node.SelectSingleNode("SubGroups");
    185       foreach (XmlNode subGroupNode in subGroupsNode.ChildNodes)
    186         AddSubGroup((IOperatorGroup)PersistenceManager.Restore(subGroupNode, restoredObjects));
    187       XmlNode operatorsNode = node.SelectSingleNode("Operators");
    188       foreach (XmlNode operatorNode in operatorsNode.ChildNodes)
    189         AddOperator((IOperator)PersistenceManager.Restore(operatorNode, restoredObjects));
    190     }
    191     #endregion
    192137  }
    193138}
Note: See TracChangeset for help on using the changeset viewer.