Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/14/08 17:49:47 (16 years ago)
Author:
gkronber
Message:

created a branch that uses XmlTextWriter instead of XMLDocument to save documents. Investigating ticket #103.

Location:
branches/XmlTextWriterBranch
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/XmlTextWriterBranch/HeuristicLab.Core/OperatorBase.cs

    r76 r119  
    437437
    438438    #region Persistence Methods
    439     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    440       XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    441       XmlAttribute nameAttribute = document.CreateAttribute("Name");
    442       nameAttribute.Value = Name;
    443       node.Attributes.Append(nameAttribute);
    444       if (Breakpoint) {
    445         XmlAttribute breakpointAttribute = document.CreateAttribute("Breakpoint");
    446         breakpointAttribute.Value = Breakpoint.ToString();
    447         node.Attributes.Append(breakpointAttribute);
    448       }
    449       XmlNode subOperatorsNode = document.CreateNode(XmlNodeType.Element, "SubOperators", null);
    450       for (int i = 0; i < SubOperators.Count; i++)
    451         subOperatorsNode.AppendChild(PersistenceManager.Persist(SubOperators[i], document, persistedObjects));
    452       node.AppendChild(subOperatorsNode);
    453       XmlNode infosNode = document.CreateNode(XmlNodeType.Element, "VariableInfos", null);
    454       foreach (IVariableInfo info in myVariableInfos.Values)
    455         infosNode.AppendChild(PersistenceManager.Persist(info, document, persistedObjects));
    456       node.AppendChild(infosNode);
    457       XmlNode variablesNode = document.CreateNode(XmlNodeType.Element, "Variables", null);
    458       foreach (IVariable variable in myVariables.Values)
    459         variablesNode.AppendChild(PersistenceManager.Persist(variable, document, persistedObjects));
    460       node.AppendChild(variablesNode);
    461       return node;
     439    //public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
     440    //  XmlNode node = base.GetXmlNode(name, document, persistedObjects);
     441    //  XmlAttribute nameAttribute = document.CreateAttribute("Name");
     442    //  nameAttribute.Value = Name;
     443    //  node.Attributes.Append(nameAttribute);
     444    //  if (Breakpoint) {
     445    //    XmlAttribute breakpointAttribute = document.CreateAttribute("Breakpoint");
     446    //    breakpointAttribute.Value = Breakpoint.ToString();
     447    //    node.Attributes.Append(breakpointAttribute);
     448    //  }
     449    //  XmlNode subOperatorsNode = document.CreateNode(XmlNodeType.Element, "SubOperators", null);
     450    //  for (int i = 0; i < SubOperators.Count; i++)
     451    //    subOperatorsNode.AppendChild(PersistenceManager.Persist(SubOperators[i], document, persistedObjects));
     452    //  node.AppendChild(subOperatorsNode);
     453    //  XmlNode infosNode = document.CreateNode(XmlNodeType.Element, "VariableInfos", null);
     454    //  foreach (IVariableInfo info in myVariableInfos.Values)
     455    //    infosNode.AppendChild(PersistenceManager.Persist(info, document, persistedObjects));
     456    //  node.AppendChild(infosNode);
     457    //  XmlNode variablesNode = document.CreateNode(XmlNodeType.Element, "Variables", null);
     458    //  foreach (IVariable variable in myVariables.Values)
     459    //    variablesNode.AppendChild(PersistenceManager.Persist(variable, document, persistedObjects));
     460    //  node.AppendChild(variablesNode);
     461    //  return node;
     462    //}
     463    public override void Persist(string name, XmlWriter writer, IDictionary<Guid, IStorable> persistedObjects) {
     464      base.Persist(name, writer, persistedObjects);
     465      writer.WriteAttributeString("Name", Name);
     466      if(Breakpoint)
     467        writer.WriteAttributeString("BreakPoint", Breakpoint.ToString());
     468      writer.WriteStartElement("SubOperators");
     469      for(int i = 0; i < SubOperators.Count; i++)
     470        PersistenceManager.Persist(SubOperators[i], writer, persistedObjects);
     471      writer.WriteEndElement(); // </SubOperators>
     472      writer.WriteStartElement("VariableInfos");
     473      foreach(IVariableInfo info in myVariableInfos.Values)
     474        PersistenceManager.Persist(info, writer, persistedObjects);
     475      writer.WriteEndElement(); // </VariableInfos>
     476      writer.WriteStartElement("Variables");
     477      foreach(IVariable variable in myVariables.Values)
     478        PersistenceManager.Persist(variable, writer, persistedObjects);
     479      writer.WriteEndElement(); // </Variables>
    462480    }
    463481    public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
Note: See TracChangeset for help on using the changeset viewer.