Skip to content

Instantly share code, notes, and snippets.

@hagbarddenstore
Last active August 29, 2015 14:01
Show Gist options
  • Save hagbarddenstore/2b982508609d6177d50b to your computer and use it in GitHub Desktop.
Save hagbarddenstore/2b982508609d6177d50b to your computer and use it in GitHub Desktop.
Example that removes the need for regions
interface IRepository<TEntity>
{
TEntity FindOne(Guid id);
void Save(TEntity entity);
}
interface IUsersRepository : IRepository<User>
{
User FindOneByUsername(string username);
}
interface IGroupsRepository : IRepository<Group>
{
Group FindOneByName(string name);
}
class Database : IUsersRepository, IGroupsRepository
{
void IUsersRepository.FindOne(Guid id)
{
return FindOne<User>(id);
}
void IUsersRepository.Save(User entity)
{
Save(entity);
}
User IUsersRepository.FindOneByUsername(string username)
{
throw new NotImplementedException();
}
void IGroupsRepository.FindOne(Guid id)
{
return FindOne<Group>(id);
}
void IGroupsRepository.Save(Group entity)
{
Save(entity);
}
void IGroupsRepository.FindOneByName(string name)
{
throw new NotImplementedException();
}
private TEntity FindOne<TEntity>(Guid id)
{
throw new NotImplementedException();
}
private void Save<TEntity>(TEntity entity)
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment