Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1853 was 1853, checked in by epitzer, 15 years ago

Fix EmptyStorableClass attributes. (#603)

File size: 818 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  public 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.