Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Core/PrimitiveSerializerBase.cs @ 1848

Last change on this file since 1848 was 1823, checked in by epitzer, 15 years ago

Namespace refactoring: rename formatters & decomposers -> primitive and composite serializers. (#603)

File size: 962 bytes
Line 
1using System;
2using System.Text;
3
4namespace HeuristicLab.Persistence.Interfaces {
5
6  public abstract class PrimitiveSerializerBase<Source, SerialData> :
7      IPrimitiveSerializer<Source, SerialData>
8      where SerialData : ISerialData {
9
10    public abstract SerialData Format(Source o);
11
12    public abstract Source Parse(SerialData t);
13
14    public Type SerialDataType { get { return typeof(SerialData); } }
15
16    public Type SourceType { get { return typeof(Source); } }
17
18    ISerialData IPrimitiveSerializer.Format(object o) {
19      return Format((Source)o);
20    }
21
22    object IPrimitiveSerializer.Parse(ISerialData o) {
23      return Parse((SerialData)o);
24    }
25
26    public override string ToString() {
27      return new StringBuilder()
28        .Append(this.GetType().Name)
29        .Append('(')
30        .Append(SourceType.Name)
31        .Append("->")
32        .Append(SerialDataType.Name)
33        .ToString();
34    }
35
36  }
37
38}
Note: See TracBrowser for help on using the repository browser.