Last change
on this file since 1564 was
1564,
checked in by epitzer, 15 years ago
|
Stronger typing for formatters with the help of generics. Separate format and serial data type. (#548)
|
File size:
789 bytes
|
Line | |
---|
1 | using System.Collections;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System;
|
---|
4 | using HeuristicLab.Persistence.Core;
|
---|
5 | using System.Globalization;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Persistence.Default.Xml.Compact {
|
---|
8 |
|
---|
9 | [EmptyStorableClass]
|
---|
10 | public class DoubleList2XmlFormatter : NumberEnumeration2XmlFormatterBase<List<double>> {
|
---|
11 |
|
---|
12 | protected override void Add(IEnumerable enumeration, object o) {
|
---|
13 | ((List<double>)enumeration).Add((int)o);
|
---|
14 | }
|
---|
15 |
|
---|
16 | protected override IEnumerable Instantiate() {
|
---|
17 | return new List<double>();
|
---|
18 | }
|
---|
19 |
|
---|
20 | protected override string FormatValue(object o) {
|
---|
21 | return ((double)o).ToString("r", CultureInfo.InvariantCulture);
|
---|
22 | }
|
---|
23 |
|
---|
24 | protected override object ParseValue(string o) {
|
---|
25 | return double.Parse(o);
|
---|
26 | }
|
---|
27 |
|
---|
28 | }
|
---|
29 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.