Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/09/09 15:15:31 (16 years ago)
Author:
epitzer
Message:

added primitive serializers for bool and DateTime. (#506)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/Persistence/PrimitiveSerializers.cs

    r1312 r1315  
    4545    }
    4646  }
     47  public class Boolean2XmlSerializer : IPrimitiveSerializer {   
     48    public Type Type { get { return typeof(bool); } }   
     49    public object Serialize(object o) {
     50      return ((bool)o).ToString();
     51    }
     52    public object DeSerialize(object o) {
     53      return bool.Parse((string)o);
     54    }
     55  }
     56  public class DateTime2XmlSerializer : IPrimitiveSerializer {   
     57    public Type Type { get { return typeof(DateTime); } }     
     58    public object Serialize(object o) {
     59      return ((DateTime)o).Ticks.ToString();     
     60    }
     61    public object DeSerialize(object o) {
     62      return new DateTime(long.Parse((string)o));
     63    }
     64  }
    4765}
Note: See TracChangeset for help on using the changeset viewer.