Changeset 1667 for trunk/sources/HeuristicLab.Core/3.3/VariableInfo.cs
- Timestamp:
- 04/27/09 14:18:39 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/VariableInfo.cs
r1529 r1667 24 24 using System.Text; 25 25 using System.Xml; 26 using HeuristicLab.Persistence.Default.Decomposers.Storable; 26 27 27 28 namespace HeuristicLab.Core { … … 30 31 /// </summary> 31 32 public class VariableInfo : ItemBase, IVariableInfo { 33 34 [Storable] 32 35 private string myActualName; 33 36 /// <summary> … … 44 47 } 45 48 } 49 50 [Storable] 46 51 private string myFormalName; 47 52 /// <summary> … … 51 56 get { return myFormalName; } 52 57 } 58 59 [Storable] 53 60 private string myDescription; 54 61 /// <summary> … … 58 65 get { return myDescription; } 59 66 } 67 68 [Storable] 60 69 private Type myDataType; 61 70 /// <summary> … … 65 74 get { return myDataType; } 66 75 } 76 77 [Storable] 67 78 private VariableKind myKind; 68 79 /// <summary> … … 72 83 get { return myKind; } 73 84 } 85 86 [Storable] 74 87 private bool myLocal; 75 88 /// <summary> … … 162 175 LocalChanged(this, new EventArgs()); 163 176 } 164 165 #region Persistence Methods166 /// <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 be232 /// 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 #endregion247 177 } 248 178 }
Note: See TracChangeset
for help on using the changeset viewer.