let's first see some live example of how to use the Interfaces to express the idea of something abstract.
First of all, let 's see the Ikey interface and some of the other interfaces.
public interface IKey<TEntity> : IKey, IQuery<TEntity> { } public interface IKey : IEquatable<IKey> { } public interface IQuery<TEntity> : IEquatable<IQuery<TEntity>> { }
So let's break down.
First of all, the IKey interface is inherit from IEquatable<IKey>, which implies that the IKey instance should be able to compare with another instance of IKey (which is the type parameter of base IEquatable).
then there is the Generic version of the interface, which is IKey<TEntity>; THis interface will inherit the IKey interface, which basically means that any Generic version of the Ikey interface is also a IKey and should be able to compare with any other IKey<TEntity> instance (the TEntity type parameter can can NOT different); --- or in other word, a Generic Form interface is also a type of the non-generic form of interfaces.
Last, let's see the IQuery interface, this interface is nearly the same as the IKey (non-generic form interface) but IQuery interface is a generic version of interface.
so by combining the interface together, it means that
public interface IKey<TEntity> : IKey, IQuery<TEntity>
IKey<TEntity> is the an interface that can compare with IKey<AnotherTEntity> or can compare with Ikey or can compare with Key<TEntity> (the same type parameter).
Herei s one thought, why not to have the following signature?
public interface IKey<TEntity> : IKey, IEquatable<TEntity>
TODO:
add some concrete class that implements those inerfaces.