Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/Char2XmlFormatter.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: 715 bytes
Line 
1using System;
2using HeuristicLab.Persistence.Core;
3using HeuristicLab.Persistence.Interfaces;
4using System.Reflection;
5using System.Globalization;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.Persistence.Default.Xml.Primitive {
9
10  [EmptyStorableClass]
11  public class Char2XmlSerializer : PrimitiveSerializerBase<char, XmlString> { 
12   
13    public override XmlString Format(char c) {
14      return new XmlString(new string(c, 1));
15    }
16
17    public override char Parse(XmlString x) {
18      if (x.Data.Length != 1)
19        throw new PersistenceException("Invalid character format, XML string length != 1");
20      return x.Data[0];
21    }
22  }
23}
Note: See TracBrowser for help on using the repository browser.