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
|
Rev | Line | |
---|
[1454] | 1 | using System;
|
---|
| 2 | using HeuristicLab.Persistence.Core;
|
---|
| 3 | using HeuristicLab.Persistence.Interfaces;
|
---|
[1823] | 4 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[1454] | 5 |
|
---|
| 6 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
| 7 |
|
---|
| 8 | [EmptyStorableClass]
|
---|
[1823] | 9 | public class DateTime2XmlSerializer : PrimitiveXmlSerializerBase<DateTime> {
|
---|
[1566] | 10 |
|
---|
[1564] | 11 | public override XmlString Format(DateTime dt) {
|
---|
[1566] | 12 | return new XmlString(dt.Ticks.ToString());
|
---|
[1454] | 13 | }
|
---|
| 14 |
|
---|
[1564] | 15 | public override DateTime Parse(XmlString x) {
|
---|
[1625] | 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 | }
|
---|
[1454] | 21 | }
|
---|
| 22 |
|
---|
| 23 | }
|
---|
| 24 |
|
---|
[1566] | 25 |
|
---|
[1454] | 26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.