Created
November 10, 2009 08:44
-
-
Save PeterLehmann/230747 to your computer and use it in GitHub Desktop.
simple identitymap interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// identity map pattern | |
/// </summary> | |
/// <typeparam name="T">class</typeparam> | |
/// <typeparam name="TIdentity">key type there index <typeparamref name="T"/></typeparam> | |
public interface IIdentityMap<T, TIdentity> where T : class | |
{ | |
/// <summary> | |
/// add a product to the map | |
/// </summary> | |
/// <param name="item">a instance of <typeparamref name="T"/></param> | |
/// <param name="identity">the identity of <typeparamref name="T"/></param> | |
/// <exception cref="ArgumentNullException">item can't be null</exception> | |
/// <exception cref="InvalidProgramException">can't add the same item more then ones</exception> | |
void AddItem(TIdentity identity, T item); | |
/// <summary> | |
/// get a item from the map if can't find one in the map will look in dao for it and add it to the map | |
/// </summary> | |
/// <param name="id">identity for a item</param> | |
/// <returns>a instance of <typeparamref name="T"/> or null</returns> | |
T GetById(TIdentity id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment