Reputation: 869
I have Interface IRepository and Class Repository with parameter constructor which Implement IRepository. Both Class and Interface are generic. I want to pass this parameter while registering. The code is as follows:
public interface IRepository<T> where T : class, new()
{
public Task<int> InsertAsync(T entity);
}
public class Repository<T> : IRepository<T> where T : class, new()
{
public MobileServiceClient MobileService { get; set; }
public Repository(MobileServiceClient mobileService)
{
MobileService = mobileService;
}
public async Task<int> InsertAsync(T entity)
{
var table = MobileService.GetSyncTable<T>();
await table.InsertAsync(entity);
return 1;
}
}
I did generic class registration like this
Container.Register(typeof(IRepository<>), typeof(Repository<>));
I am not finding way to pass parameter while registering.
Upvotes: 2
Views: 604