1 | using System;
|
---|
2 |
|
---|
3 | namespace HeuristicLab.Persistence.Interfaces {
|
---|
4 |
|
---|
5 | /// <summary>
|
---|
6 | /// Marker interface primitive serializers. Transform data of type SourceType
|
---|
7 | /// into the serialization format SerialDataType. Derive from PrimitiveSerializerBase instead
|
---|
8 | /// of implementing this interface.
|
---|
9 | /// </summary>
|
---|
10 | public interface IPrimitiveSerializer {
|
---|
11 |
|
---|
12 | /// <summary>
|
---|
13 | /// Gets the type of the serial data.
|
---|
14 | /// </summary>
|
---|
15 | /// <value>The type of the serial data.</value>
|
---|
16 | Type SerialDataType { get; }
|
---|
17 |
|
---|
18 | /// <summary>
|
---|
19 | /// Gets the source type.
|
---|
20 | /// </summary>
|
---|
21 | /// <value>The type of the source.</value>
|
---|
22 | Type SourceType { get; }
|
---|
23 |
|
---|
24 | /// <summary>
|
---|
25 | /// Creates a serialized representation of the provided object.
|
---|
26 | /// </summary>
|
---|
27 | /// <param name="o">The object.</param>
|
---|
28 | /// <returns>A serialized version of the object.</returns>
|
---|
29 | ISerialData Format(object o);
|
---|
30 |
|
---|
31 |
|
---|
32 | /// <summary>
|
---|
33 | /// Creates a fresh object instance using the serializes data..
|
---|
34 | /// </summary>
|
---|
35 | /// <param name="data">The data.</param>
|
---|
36 | /// <returns>A fresh object instance.</returns>
|
---|
37 | object Parse(ISerialData data);
|
---|
38 | }
|
---|
39 |
|
---|
40 | /// <summary>
|
---|
41 | /// Marker interface primitive serializers. Transform data of type SourceType
|
---|
42 | /// into the serialization format SerialDataType. Derive from PrimitiveSerializerBase instead
|
---|
43 | /// of implementing this interface.
|
---|
44 | /// </summary>
|
---|
45 | /// <typeparam name="Source">The source type.</typeparam>
|
---|
46 | /// <typeparam name="SerialData">The serialized data type.</typeparam>
|
---|
47 | public interface IPrimitiveSerializer<Source, SerialData> : IPrimitiveSerializer where SerialData : ISerialData {
|
---|
48 |
|
---|
49 | /// <summary>
|
---|
50 | /// Creates a serialized version of the provided object.
|
---|
51 | /// </summary>
|
---|
52 | /// <param name="o">The object.</param>
|
---|
53 | /// <returns>A serialized version of the object.</returns>
|
---|
54 | SerialData Format(Source o);
|
---|
55 |
|
---|
56 |
|
---|
57 | /// <summary>
|
---|
58 | /// Creates a fresh object instance from the serialized data
|
---|
59 | /// </summary>
|
---|
60 | /// <param name="data">The data.</param>
|
---|
61 | /// <returns>A fresh object instance.</returns>
|
---|
62 | Source Parse(SerialData data);
|
---|
63 | }
|
---|
64 |
|
---|
65 | } |
---|