Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/09 12:40:41 (15 years ago)
Author:
epitzer
Message:

Stronger typing for formatters with the help of generics. Separate format and serial data type. (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/FormatBase.cs

    r1556 r1564  
    33namespace HeuristicLab.Persistence.Interfaces {
    44
    5   public abstract class FormatBase : IFormat {
    6     public abstract string Name { get;  }
     5  public abstract class FormatBase<SerialDataFormat> : IFormat<SerialDataFormat> where SerialDataFormat : ISerialData {
     6
     7    public abstract string Name { get; }
     8
     9    public Type SerialDataType { get { return typeof(SerialDataFormat); } }
     10
     11    public bool Equals(FormatBase<SerialDataFormat> f) {
     12      if (f == null)
     13        return false;
     14      return f.Name == this.Name;
     15    }
     16
    717    public override bool Equals(object obj) {
    8       if (obj as IFormat == null)
    9         return false;
    10       return this.Equals((FormatBase)obj);     
     18      FormatBase<SerialDataFormat> f = obj as FormatBase<SerialDataFormat>;     
     19      return Equals(f);
    1120    }
    12     public bool Equals(FormatBase f) {
    13       return Name.Equals(f.Name);
    14     }
    15     public override int GetHashCode() {
    16       return Name.GetHashCode();
    17     }
     21   
    1822  }
     23
    1924}
Note: See TracChangeset for help on using the changeset viewer.