Skip to content

Instantly share code, notes, and snippets.

@PeterLehmann
Created November 10, 2009 08:44
Show Gist options
  • Save PeterLehmann/230747 to your computer and use it in GitHub Desktop.
Save PeterLehmann/230747 to your computer and use it in GitHub Desktop.
simple identitymap interface
/// <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