Last change
on this file since 1564 was
1564,
checked in by epitzer, 15 years ago
|
Stronger typing for formatters with the help of generics. Separate format and serial data type. (#548)
|
File size:
638 bytes
|
Line | |
---|
1 | using System;
|
---|
2 |
|
---|
3 | namespace HeuristicLab.Persistence.Interfaces {
|
---|
4 |
|
---|
5 | public abstract class FormatterBase<Source, SerialData> : IFormatter<Source, SerialData> where SerialData : ISerialData {
|
---|
6 |
|
---|
7 | public abstract SerialData Format(Source o);
|
---|
8 |
|
---|
9 | public abstract Source Parse(SerialData t);
|
---|
10 |
|
---|
11 | public Type SerialDataType { get { return typeof(SerialData); } }
|
---|
12 |
|
---|
13 | public Type SourceType { get { return typeof(Source); } }
|
---|
14 |
|
---|
15 | ISerialData IFormatter.Format(object o) {
|
---|
16 | return Format((Source)o);
|
---|
17 | }
|
---|
18 |
|
---|
19 | object IFormatter.Parse(ISerialData o) {
|
---|
20 | return Parse((SerialData)o);
|
---|
21 | }
|
---|
22 |
|
---|
23 | }
|
---|
24 |
|
---|
25 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.