Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Guid2XmlFormatter.cs @ 1683

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

Fix StackDecomposer, reverse collection before serialization (#603)

File size: 906 bytes
Line 
1using System;
2using HeuristicLab.Persistence.Core;
3using HeuristicLab.Persistence.Interfaces;
4using System.Text;
5using System.Text.RegularExpressions;
6using HeuristicLab.Persistence.Default.Decomposers.Storable;
7using System.Globalization;
8
9
10namespace HeuristicLab.Persistence.Default.Xml.Primitive {
11 
12  [EmptyStorableClass]
13  public class Guid2XmlFormatter : PrimitiveXmlFormatterBase<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.