1 | using System.Collections.Generic;
|
---|
2 | using System;
|
---|
3 | using System.Text;
|
---|
4 | using HeuristicLab.Persistence.Interfaces;
|
---|
5 | using HeuristicLab.Persistence.Core;
|
---|
6 | using System.IO;
|
---|
7 | using ICSharpCode.SharpZipLib.Zip;
|
---|
8 | using HeuristicLab.Tracing;
|
---|
9 | using log4net;
|
---|
10 | using HeuristicLab.Persistence.Core.Tokens;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.Persistence.Core {
|
---|
13 |
|
---|
14 | public abstract class GeneratorBase<T> {
|
---|
15 |
|
---|
16 | public T Format(ISerializationToken token) {
|
---|
17 | Type type = token.GetType();
|
---|
18 | if (type == typeof(BeginToken))
|
---|
19 | return Format((BeginToken)token);
|
---|
20 | if (type == typeof(EndToken))
|
---|
21 | return Format((EndToken)token);
|
---|
22 | if (type == typeof(PrimitiveToken))
|
---|
23 | return Format((PrimitiveToken)token);
|
---|
24 | if (type == typeof(ReferenceToken))
|
---|
25 | return Format((ReferenceToken)token);
|
---|
26 | if (type == typeof(NullReferenceToken))
|
---|
27 | return Format((NullReferenceToken)token);
|
---|
28 | if (type == typeof(MetaInfoBeginToken))
|
---|
29 | return Format((MetaInfoBeginToken)token);
|
---|
30 | if (type == typeof(MetaInfoEndToken))
|
---|
31 | return Format((MetaInfoEndToken)token);
|
---|
32 | throw new ApplicationException("Invalid token of type " + type.FullName);
|
---|
33 | }
|
---|
34 |
|
---|
35 | protected abstract T Format(BeginToken beginToken);
|
---|
36 | protected abstract T Format(EndToken endToken);
|
---|
37 | protected abstract T Format(PrimitiveToken primitiveToken);
|
---|
38 | protected abstract T Format(ReferenceToken referenceToken);
|
---|
39 | protected abstract T Format(NullReferenceToken nullReferenceToken);
|
---|
40 | protected abstract T Format(MetaInfoBeginToken metaInfoBeginToken);
|
---|
41 | protected abstract T Format(MetaInfoEndToken metaInfoEndToken);
|
---|
42 |
|
---|
43 | }
|
---|
44 | } |
---|