Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/09 12:40:41 (16 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/DateTime2XmlFormatter.cs

    r1454 r1564  
    66
    77  [EmptyStorableClass]
    8   public class DateTime2XmlFormatter : IFormatter {   
    9 
    10     public Type Type { get { return typeof(DateTime); } }
    11     public IFormat Format { get { return XmlFormat.Instance; } } 
    12 
    13     public object DoFormat(object o) {
    14       return ((DateTime)o).Ticks.ToString();     
     8  public class DateTime2XmlFormatter : FormatterBase<DateTime, XmlString> {   
     9   
     10    public override XmlString Format(DateTime dt) {
     11      return new XmlString(dt.Ticks.ToString());     
    1512    }
    1613
    17     public object Parse(object o) {
    18       return new DateTime(long.Parse((string)o));
     14    public override DateTime Parse(XmlString x) {
     15      return new DateTime(long.Parse(x.Data));
    1916    }
    2017
Note: See TracChangeset for help on using the changeset viewer.