Rev | Line | |
---|
[1556] | 1 | using HeuristicLab.Persistence.Interfaces;
|
---|
[1615] | 2 | using System.Reflection;
|
---|
| 3 | using System.Text;
|
---|
[1556] | 4 |
|
---|
| 5 | namespace HeuristicLab.Persistence.Core.Tokens {
|
---|
[3016] | 6 |
|
---|
| 7 | /// <summary>
|
---|
| 8 | /// Common base class for all serialization tokens.
|
---|
| 9 | /// </summary>
|
---|
[1556] | 10 | public abstract class SerializationTokenBase : ISerializationToken {
|
---|
[3016] | 11 |
|
---|
| 12 | /// <summary>
|
---|
| 13 | /// The token's name.
|
---|
| 14 | /// </summary>
|
---|
[1556] | 15 | public readonly string Name;
|
---|
[3016] | 16 |
|
---|
| 17 | /// <summary>
|
---|
| 18 | /// Initializes a new instance of the <see cref="SerializationTokenBase"/> class.
|
---|
| 19 | /// </summary>
|
---|
| 20 | /// <param name="name">The token name.</param>
|
---|
[1556] | 21 | public SerializationTokenBase(string name) {
|
---|
| 22 | Name = name;
|
---|
| 23 | }
|
---|
[3016] | 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>
|
---|
[1615] | 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 | }
|
---|
[1556] | 40 | }
|
---|
| 41 |
|
---|
| 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.