Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/27/09 14:45:44 (16 years ago)
Author:
epitzer
Message:

Migrate HL.Data-3.3 to new persistence library. (#603)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/3.3/DoubleArrayData.cs

    r1529 r1669  
    6464      return new DoubleArrayDataView(this);
    6565    }
    66 
    67     /// <summary>
    68     /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
    69     /// </summary>
    70     /// <remarks>The double elements of the array are saved in the node's inner text as string,
    71     /// each element, whose format depends on the locale culture info, separated by a semicolon.</remarks>
    72     /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
    73     /// <param name="document">The <see cref="XmlDocument"/> where the data is saved.</param>
    74     /// <param name="persistedObjects">A dictionary of all already persisted objects. (Needed to avoid cycles.)</param>
    75     /// <returns>The saved <see cref="XmlNode"></see>.</returns>
    76     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    77       XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    78       node.InnerText = ToString(CultureInfo.InvariantCulture.NumberFormat);
    79       return node;
    80     }
    8166   
    82     /// <summary>
    83     /// Loads the persisted double array from the specified <paramref name="node"/>.
    84     /// </summary>
    85     /// <remarks>The double elemets of the array must be saved in the inner text of the node as string,
    86     /// each element separated by a semicolon and formatted according to the locale culture info and
    87     /// its number format (see <see cref="GetXmlNode"/>).</remarks>
    88     /// <exception cref="System.FormatException">Thrown when a saved element cannot be parsed as a double value.</exception>
    89     /// <param name="node">The <see cref="XmlNode"></see> where the instance is saved.</param>
    90     /// <param name="restoredObjects">A dictionary of all already restored objects. (Needed to avoid cycles.)</param>
    91     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    92       base.Populate(node, restoredObjects);
    93       string[] tokens = node.InnerText.Split(';');
    94       double[] data = new double[tokens.Length];
    95       for(int i = 0; i < data.Length; i++)
    96         if(double.TryParse(tokens[i], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out data[i]) == false) {
    97           throw new FormatException("Can't parse " + tokens[i] + " as double value.");
    98         }
    99       Data = data;
    100     }
    101 
    10267    /// <summary>
    10368    /// The string representation of the array, formatted according to the given <paramref name="format"/>.
Note: See TracChangeset for help on using the changeset viewer.