Last change
on this file since 3188 was
3036,
checked in by epitzer, 15 years ago
|
make most serializers internal and complete API documentation (#548)
|
File size:
1.0 KB
|
Rev | Line | |
---|
[1454] | 1 | using System;
|
---|
| 2 | using HeuristicLab.Persistence.Core;
|
---|
| 3 | using HeuristicLab.Persistence.Interfaces;
|
---|
[1554] | 4 | using System.Reflection;
|
---|
| 5 | using System.Globalization;
|
---|
[1454] | 6 |
|
---|
[1566] | 7 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
| 8 |
|
---|
[3036] | 9 | internal sealed class Double2XmlSerializer : PrimitiveXmlSerializerBase<double> {
|
---|
[1566] | 10 |
|
---|
[1958] | 11 | public static double ParseG17(string s) {
|
---|
| 12 | double d;
|
---|
| 13 | if (double.TryParse(s,
|
---|
| 14 | NumberStyles.AllowDecimalPoint |
|
---|
| 15 | NumberStyles.AllowExponent |
|
---|
| 16 | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out d))
|
---|
| 17 | return d;
|
---|
| 18 | throw new FormatException(
|
---|
| 19 | String.Format("Invalid G17 number format \"{0}\" could not be parsed", s));
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | public static string FormatG17(double d) {
|
---|
| 23 | return d.ToString("g17", CultureInfo.InvariantCulture);
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | public override XmlString Format(double d) {
|
---|
| 27 | return new XmlString(FormatG17(d));
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public override double Parse(XmlString t) {
|
---|
| 31 | return ParseG17(t.Data);
|
---|
| 32 | }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 |
|
---|
[1454] | 38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.