Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Core/GeneratorBase.cs @ 2007

Last change on this file since 2007 was 1623, checked in by epitzer, 16 years ago

Namespace refactoring, visibility check (#548)

File size: 1.6 KB
Line 
1using System.Collections.Generic;
2using System;
3using System.Text;
4using HeuristicLab.Persistence.Interfaces;
5using HeuristicLab.Persistence.Core;
6using System.IO;
7using ICSharpCode.SharpZipLib.Zip;
8using HeuristicLab.Tracing;
9using log4net;
10using HeuristicLab.Persistence.Core.Tokens;
11
12namespace 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}
Note: See TracBrowser for help on using the repository browser.