Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1835 was 1823, checked in by epitzer, 16 years ago

Namespace refactoring: rename formatters & decomposers -> primitive and composite serializers. (#603)

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