Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatBase.cs @ 3036

Last change on this file since 3036 was 3036, checked in by epitzer, 15 years ago

make most serializers internal and complete API documentation (#548)

File size: 2.1 KB
Line 
1using System;
2using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
3
4namespace HeuristicLab.Persistence.Interfaces {
5
6  /// <summary>
7  /// Common base class for defining a new serialization format.
8  /// </summary>
9  /// <typeparam name="SerialDataFormat">The type of the serial data format.</typeparam>
10  [StorableClass]
11  public abstract class FormatBase<SerialDataFormat> : IFormat<SerialDataFormat> where SerialDataFormat : ISerialData {
12
13    /// <summary>
14    /// Gets the format's name.
15    /// </summary>
16    /// <value>The format's name.</value>
17    public abstract string Name { get; }
18   
19    /// <summary>
20    /// Datatype that describes the atoms used for serialization serialization.
21    /// </summary>
22    public Type SerialDataType { get { return typeof(SerialDataFormat); } }
23
24    /// <summary>
25    /// Compares formats by name.
26    /// </summary>
27    /// <param name="f">The format.</param>
28    /// <returns>wheter this object and f are equal by name.</returns>
29    public bool Equals(FormatBase<SerialDataFormat> f) {
30      if (f == null)
31        return false;
32      return f.Name == this.Name;
33    }
34
35    /// <summary>
36    /// Compares foramts by name.
37    /// </summary>
38    /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
39    /// <returns>
40    ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
41    /// </returns>
42    /// <exception cref="T:System.NullReferenceException">
43    /// The <paramref name="obj"/> parameter is null.
44    /// </exception>
45    public override bool Equals(object obj) {
46      FormatBase<SerialDataFormat> f = obj as FormatBase<SerialDataFormat>;
47      return Equals(f);
48    }
49
50    /// <summary>
51    /// Returns a hash code for this instance.
52    /// </summary>
53    /// <returns>
54    /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
55    /// </returns>
56    public override int GetHashCode() {
57      return Name.GetHashCode();
58    }
59
60  }
61
62}
Note: See TracBrowser for help on using the repository browser.