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:
917 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using HeuristicLab.Persistence.Core;
|
---|
3 | using HeuristicLab.Persistence.Interfaces;
|
---|
4 | using System.Text;
|
---|
5 | using System.Text.RegularExpressions;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 | using System.Globalization;
|
---|
8 |
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
11 |
|
---|
12 | [EmptyStorableClass]
|
---|
13 | public class Guid2XmlSerializer : PrimitiveXmlSerializerBase<Guid> {
|
---|
14 |
|
---|
15 | public override XmlString Format(Guid o) {
|
---|
16 | return new XmlString(o.ToString("D", CultureInfo.InvariantCulture));
|
---|
17 | }
|
---|
18 |
|
---|
19 | public override Guid Parse(XmlString t) {
|
---|
20 | try {
|
---|
21 | return new Guid(t.Data);
|
---|
22 | } catch (FormatException x) {
|
---|
23 | throw new PersistenceException("Cannot parse Guid string representation.", x);
|
---|
24 | } catch (OverflowException x) {
|
---|
25 | throw new PersistenceException("Overflow during Guid parsing.", x);
|
---|
26 | }
|
---|
27 | }
|
---|
28 | }
|
---|
29 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.