Free cookie consent management tool by TermsFeed Policy Generator

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

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: 917 bytes
Line 
1using System;
2using HeuristicLab.Persistence.Core;
3using HeuristicLab.Persistence.Interfaces;
4using System.Text;
5using System.Text.RegularExpressions;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7using System.Globalization;
8
9
10namespace 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.