Last change
on this file since 1823 was
1823,
checked in by epitzer, 15 years ago
|
Namespace refactoring: rename formatters & decomposers -> primitive and composite serializers. (#603)
|
File size:
912 bytes
|
Rev | Line | |
---|
[1683] | 1 | using System;
|
---|
| 2 | using HeuristicLab.Persistence.Core;
|
---|
| 3 | using HeuristicLab.Persistence.Interfaces;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Text.RegularExpressions;
|
---|
[1823] | 6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[1683] | 7 | using System.Globalization;
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
| 11 |
|
---|
| 12 | [EmptyStorableClass]
|
---|
[1823] | 13 | public class TimeSpan2XmlSerializer : PrimitiveXmlSerializerBase<TimeSpan> {
|
---|
[1683] | 14 |
|
---|
| 15 | public override XmlString Format(TimeSpan o) {
|
---|
| 16 | return new XmlString(o.ToString());
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | public override TimeSpan Parse(XmlString t) {
|
---|
| 20 | try {
|
---|
| 21 | return TimeSpan.Parse(t.Data);
|
---|
| 22 | } catch (FormatException x) {
|
---|
| 23 | throw new PersistenceException("Cannot parse TimeSpan string representation.", x);
|
---|
| 24 | } catch (OverflowException x) {
|
---|
| 25 | throw new PersistenceException("Overflow during TimeSpan parsing.", x);
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.