Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Guid2XmlSerializer.cs @ 3036

Last change on this file since 3036 was 3036, checked in by epitzer, 14 years ago

make most serializers internal and complete API documentation (#548)

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