Structuremap Configuration with generics
- by DarthVader
I have IRepository interface with which i want to use NHibernateRepository.
How do i configure it with structure map?
protected void ConfigureDependencies()
{
ObjectFactory.Initialize(
x =>
{
x.For<ILogger>().Use<Logger>();
x.For<IRepository<T>>().Use<NHibernateRepository<T>>();
}
);
}
I m getting an error on T.
Another question I have is if it s OK to make an ApplicationContext static class, configure it with structure map and provide instances with it?
I have read that static classes are bad, but I dont want to initialize the ApplicationContext class that I have the injections everywhere.
What s the best practice for this?
Thanks.