Line | |
---|
1 | using HeuristicLab.Persistence.Interfaces;
|
---|
2 | using System.Reflection;
|
---|
3 | using System.Text;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Persistence.Core.Tokens {
|
---|
6 |
|
---|
7 | /// <summary>
|
---|
8 | /// Common base class for all serialization tokens.
|
---|
9 | /// </summary>
|
---|
10 | public abstract class SerializationTokenBase : ISerializationToken {
|
---|
11 |
|
---|
12 | /// <summary>
|
---|
13 | /// The token's name.
|
---|
14 | /// </summary>
|
---|
15 | public readonly string Name;
|
---|
16 |
|
---|
17 | /// <summary>
|
---|
18 | /// Initializes a new instance of the <see cref="SerializationTokenBase"/> class.
|
---|
19 | /// </summary>
|
---|
20 | /// <param name="name">The token name.</param>
|
---|
21 | public SerializationTokenBase(string name) {
|
---|
22 | Name = name;
|
---|
23 | }
|
---|
24 |
|
---|
25 | /// <summary>
|
---|
26 | /// Returns a <see cref="System.String"/> that represents this instance.
|
---|
27 | /// </summary>
|
---|
28 | /// <returns>
|
---|
29 | /// A <see cref="System.String"/> that represents this instance.
|
---|
30 | /// </returns>
|
---|
31 | public override string ToString() {
|
---|
32 | StringBuilder sb = new StringBuilder();
|
---|
33 | sb.Append(this.GetType().Name).Append('(');
|
---|
34 | foreach (FieldInfo fi in this.GetType().GetFields()) {
|
---|
35 | sb.Append(fi.Name).Append('=').Append(fi.GetValue(this)).Append(", ");
|
---|
36 | }
|
---|
37 | sb.Append(')');
|
---|
38 | return sb.ToString();
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.