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 | |
---|
1 | using System;
|
---|
2 | using HeuristicLab.Persistence.Core;
|
---|
3 | using HeuristicLab.Persistence.Interfaces;
|
---|
4 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
5 |
|
---|
6 | namespace 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.