Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/DateTime2XmlSerializer.cs @ 2115

Last change on this file since 2115 was 1853, checked in by epitzer, 16 years ago

Fix EmptyStorableClass attributes. (#603)

File size: 640 bytes
RevLine 
[1454]1using System;
2using HeuristicLab.Persistence.Core;
3using HeuristicLab.Persistence.Interfaces;
4
5namespace 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.