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

    r1529 r1667  
    2424using System.Text;
    2525using System.Xml;
     26using HeuristicLab.Persistence.Default.Decomposers.Storable;
    2627
    2728namespace HeuristicLab.Core {
     
    3031  /// </summary>
    3132  public class VariableInfo : ItemBase, IVariableInfo {
     33
     34    [Storable]
    3235    private string myActualName;
    3336    /// <summary>
     
    4447      }
    4548    }
     49
     50    [Storable]
    4651    private string myFormalName;
    4752    /// <summary>
     
    5156      get { return myFormalName; }
    5257    }
     58
     59    [Storable]
    5360    private string myDescription;
    5461    /// <summary>
     
    5865      get { return myDescription; }
    5966    }
     67
     68    [Storable]
    6069    private Type myDataType;
    6170    /// <summary>
     
    6574      get { return myDataType; }
    6675    }
     76
     77    [Storable]
    6778    private VariableKind myKind;
    6879    /// <summary>
     
    7283      get { return myKind; }
    7384    }
     85
     86    [Storable]
    7487    private bool myLocal;
    7588    /// <summary>
     
    162175        LocalChanged(this, new EventArgs());
    163176    }
    164 
    165     #region Persistence Methods
    166     /// <summary>
    167     /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
    168     /// </summary>
    169     /// <remarks>Calls <see cref="StorableBase.GetXmlNode"/> of base class <see cref="ItemBase"/>. <br/>
    170     /// A quick overview how the single elements of the current instance are saved:
    171     /// <list type="bullet">
    172     /// <item>
    173     /// <term>Actual name: </term>
    174     /// <description>Saved as <see cref="XmlAttribute"/> with tag name <c>ActualName</c>.</description>
    175     /// </item>
    176     /// <item>
    177     /// <term>Formal name: </term>
    178     /// <description>Saves as <see cref="XmlAttribute"/> with tag name <c>FormalName</c>.</description>
    179     /// </item>
    180     /// <item>
    181     /// <term>Description: </term>
    182     /// <description>Saved as <see cref="XmlAttribute"/> with tag name <c>Description</c>.</description>
    183     /// </item>
    184     /// <item><term>Data type: </term>
    185     /// <description>Saved as <see cref="XmlAttribute"/> with tag name <c>DataType</c>.</description>
    186     /// </item>
    187     /// <item>
    188     /// <term>Kind: </term>
    189     /// <description>Saved as <see cref="XmlAttribute"/> with tag name <c>Kind</c>.</description>
    190     /// </item>
    191     /// <item>
    192     /// <term>Local: </term>
    193     /// <description>Saved as <see cref="XmlAttribute"/> with tag name <c>Local</c>.</description>
    194     /// </item>
    195     /// </list></remarks>
    196     /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
    197     /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
    198     /// <param name="persistedObjects">The dictionary of all already persisted objects. (Needed to avoid cycles.)</param>
    199     /// <returns>The saved <see cref="XmlNode"/>.</returns>
    200     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    201       XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    202       XmlAttribute actualNameAttribute = document.CreateAttribute("ActualName");
    203       actualNameAttribute.Value = ActualName;
    204       node.Attributes.Append(actualNameAttribute);
    205 
    206       XmlAttribute formalNameAttribute = document.CreateAttribute("FormalName");
    207       formalNameAttribute.Value = FormalName;
    208       node.Attributes.Append(formalNameAttribute);
    209 
    210       XmlAttribute descriptionAttribute = document.CreateAttribute("Description");
    211       descriptionAttribute.Value = Description;
    212       node.Attributes.Append(descriptionAttribute);
    213 
    214       XmlAttribute dataTypeAttribute = document.CreateAttribute("DataType");
    215       dataTypeAttribute.Value = PersistenceManager.BuildTypeString(DataType);
    216       node.Attributes.Append(dataTypeAttribute);
    217 
    218       XmlAttribute kindAttribute = document.CreateAttribute("Kind");
    219       kindAttribute.Value = Kind.ToString();
    220       node.Attributes.Append(kindAttribute);
    221 
    222       XmlAttribute localAttribute = document.CreateAttribute("Local");
    223       localAttribute.Value = Local.ToString();
    224       node.Attributes.Append(localAttribute);
    225 
    226       return node;
    227     }
    228     /// <summary>
    229     /// Loads the persisted variable info from the specified <paramref name="node"/>.
    230     /// </summary>
    231     /// <remarks>See <see cref="GetXmlNode"/> for further information on how the variable info must be
    232     /// saved. <br/>
    233     /// Calls <see cref="StorableBase.Populate"/> of base class <see cref="ItemBase"/>.</remarks>
    234     /// <param name="node">The <see cref="XmlNode"/> where the variable info is saved.</param>
    235     /// <param name="restoredObjects">The dictionary of all already restored objects.
    236     /// (Needed to avoid cycles.)</param>
    237     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    238       base.Populate(node, restoredObjects);
    239       myActualName = node.Attributes["ActualName"].Value;
    240       myFormalName = node.Attributes["FormalName"].Value;
    241       myDescription = node.Attributes["Description"].Value;
    242       myDataType = Type.GetType(node.Attributes["DataType"].Value, true);
    243       myKind = (VariableKind)Enum.Parse(typeof(VariableKind), node.Attributes["Kind"].Value);
    244       myLocal = bool.Parse(node.Attributes["Local"].Value);
    245     }
    246     #endregion
    247177  }
    248178}
Note: See TracChangeset for help on using the changeset viewer.