Structuremap Configuration with generics
Posted
by
DarthVader
on Stack Overflow
See other posts from Stack Overflow
or by DarthVader
Published on 2012-04-15T23:21:03Z
Indexed on
2012/04/15
23:29 UTC
Read the original article
Hit count: 218
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.
© Stack Overflow or respective owner