Suppose I have a generic interface and a generic implementation. How do I register all usages?
Specifically, I have the following (reduced for simplicity):
public interface IRepository<T> where T : TableEntity
{
T GetById(string partitionKey, string rowKey);
void Insert(T entity);
void Update(T entity);
void Update(string partitionKey, string rowKey, Action<T> updateAction);
void Delete(T entity);
IQueryable<T> Table { get; }
}
public class AzureRepository<T> : IRepository<T> where T : TableEntity
{
...
}
Do I need to register all implementations one by one, like so:
container.Register<IRepository<Entity1>, AzureRepository<Entity1>>();
container.Register<IRepository<Entity2>, AzureRepository<Entity2>>();
container.Register<IRepository<Entity3>, AzureRepository<Entity3>>();
...
Or is there a shorter way?