Rev | Line | |
---|
[1454] | 1 | using System;
|
---|
| 2 | using HeuristicLab.Persistence.Core;
|
---|
| 3 | using HeuristicLab.Persistence.Interfaces;
|
---|
| 4 |
|
---|
| 5 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
| 6 |
|
---|
[1823] | 7 | public class DateTime2XmlSerializer : PrimitiveXmlSerializerBase<DateTime> {
|
---|
[1566] | 8 |
|
---|
[1564] | 9 | public override XmlString Format(DateTime dt) {
|
---|
[1566] | 10 | return new XmlString(dt.Ticks.ToString());
|
---|
[1454] | 11 | }
|
---|
| 12 |
|
---|
[1564] | 13 | public override DateTime Parse(XmlString x) {
|
---|
[1625] | 14 | try {
|
---|
| 15 | return new DateTime(long.Parse(x.Data));
|
---|
| 16 | } catch (Exception e) {
|
---|
| 17 | throw new PersistenceException("Exception caugth while trying to reconstruct DateTime object.", e);
|
---|
| 18 | }
|
---|
[1454] | 19 | }
|
---|
| 20 |
|
---|
| 21 | }
|
---|
| 22 |
|
---|
[1566] | 23 |
|
---|
[1454] | 24 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.