Last change
on this file since 1835 was
1823,
checked in by epitzer, 16 years ago
|
Namespace refactoring: rename formatters & decomposers -> primitive and composite serializers. (#603)
|
File size:
910 bytes
|
Rev | Line | |
---|
[1554] | 1 | using System;
|
---|
| 2 | using HeuristicLab.Persistence.Core;
|
---|
| 3 | using HeuristicLab.Persistence.Interfaces;
|
---|
| 4 | using System.Reflection;
|
---|
| 5 | using System.Globalization;
|
---|
| 6 |
|
---|
[1566] | 7 | namespace HeuristicLab.Persistence.Default.Xml.Primitive {
|
---|
[1554] | 8 |
|
---|
[1823] | 9 | public abstract class SimpleNumber2XmlSerializerBase<T> : PrimitiveXmlSerializerBase<T> {
|
---|
[1554] | 10 |
|
---|
| 11 | private static MethodInfo ParseMethod = typeof(T)
|
---|
| 12 | .GetMethod(
|
---|
| 13 | "Parse",
|
---|
| 14 | BindingFlags.Static | BindingFlags.Public,
|
---|
| 15 | null,
|
---|
| 16 | CallingConventions.Standard,
|
---|
| 17 | new[] { typeof(string) },
|
---|
| 18 | null);
|
---|
| 19 |
|
---|
[1564] | 20 | public override XmlString Format(T t) {
|
---|
| 21 | return new XmlString(t.ToString());
|
---|
[1554] | 22 | }
|
---|
[1564] | 23 | public override T Parse(XmlString x) {
|
---|
[1625] | 24 | try {
|
---|
| 25 | return (T)ParseMethod.Invoke(null, new[] { x.Data });
|
---|
| 26 | } catch (Exception e) {
|
---|
| 27 | throw new PersistenceException("Could not parse simple number.", e);
|
---|
| 28 | }
|
---|
[1554] | 29 | }
|
---|
[1566] | 30 | }
|
---|
[1554] | 31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.