Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 2994 was 2994, checked in by epitzer, 14 years ago

Make StorableClass attribute compulsory for StorableSerializer to work, add named property StorableClassType to choose between Empty and MarkedOnly, later other options will be added. (#548)

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