Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/09 12:40:41 (15 years ago)
Author:
epitzer
Message:

Stronger typing for formatters with the help of generics. Separate format and serial data type. (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/SimpleNumber2XmlFormatterBase.cs

    r1554 r1564  
    77namespace HeuristicLab.Persistence.Default.Xml.Primitive { 
    88
    9   public abstract class SimpleNumber2XmlFormatterBase<T> : IFormatter {
    10 
    11     public Type Type { get { return typeof(T); } }
    12 
    13     public IFormat Format { get { return XmlFormat.Instance; } }
     9  public abstract class SimpleNumber2XmlFormatterBase<T> : FormatterBase<T, XmlString> {
    1410
    1511    private static MethodInfo ParseMethod = typeof(T)
     
    2218        null);
    2319
    24     public object DoFormat(object o) {
    25       return ((T)o).ToString();
     20    public override XmlString Format(T t) {
     21      return new XmlString(t.ToString());
    2622    }
    27     public object Parse(object o) {
    28       return ParseMethod.Invoke(null, new[] { o });     
     23    public override T Parse(XmlString x) {
     24      return (T)ParseMethod.Invoke(null, new[] { x.Data });     
    2925    }
    3026  } 
Note: See TracChangeset for help on using the changeset viewer.