Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone3/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
Line 
1using System;
2using HeuristicLab.Persistence.Core;
3using HeuristicLab.Persistence.Interfaces;
4
5namespace HeuristicLab.Persistence.Default.Xml.Primitive {
6
7  public class DateTime2XmlSerializer : PrimitiveXmlSerializerBase<DateTime> {
8
9    public override XmlString Format(DateTime dt) {
10      return new XmlString(dt.Ticks.ToString());
11    }
12
13    public override DateTime Parse(XmlString x) {
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      }
19    }
20
21  }
22
23
24}
Note: See TracBrowser for help on using the repository browser.