Changeset 1669 for trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs
- Timestamp:
- 04/27/09 14:45:44 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs
r1529 r1669 76 76 return clone; 77 77 } 78 79 /// <summary>80 /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.81 /// </summary>82 /// <remarks>The double value is saved in the node's inner text as string,83 /// its format depending on the local culture info and its number format.</remarks>84 /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>85 /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>86 /// <param name="persistedObjects">A dictionary of all already persisted objects. (Needed to avoid cycles.)</param>87 /// <returns>The saved <see cref="XmlNode"/>.</returns>88 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {89 XmlNode node = base.GetXmlNode(name, document, persistedObjects);90 node.InnerText = Data.ToString("r", CultureInfo.InvariantCulture.NumberFormat);91 return node;92 }93 /// <summary>94 /// Loads the persisted double value from the specified <paramref name="node"/>.95 /// </summary>96 /// <remarks>The double value must be saved in the node's inner text as a string and97 /// formatted according to the locale culture info and98 /// its number format (see <see cref="GetXmlNode"/>).</remarks>99 /// <exception cref="System.FormatException">Thrown when the saved value cannot be parsed as a double value.</exception>100 /// <param name="node">The <see cref="XmlNode"/> where the double is saved.</param>101 /// <param name="restoredObjects">A dictionary of all already restored objects. (Needed to avoid cycles.)</param>102 public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {103 base.Populate(node, restoredObjects);104 double data;105 if(double.TryParse(node.InnerText, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data) == true) {106 Data = data;107 } else {108 throw new FormatException("Can't parse " + node.InnerText + " as double value.");109 }110 }111 78 } 112 79 }
Note: See TracChangeset
for help on using the changeset viewer.