Microsoft Unity, parameters in constructor
Posted
by raffaeu
on Stack Overflow
See other posts from Stack Overflow
or by raffaeu
Published on 2010-04-08T12:34:57Z
Indexed on
2010/04/08
12:43 UTC
Read the original article
Hit count: 385
unity
|enterpriselibrary
I am using Unity with MVC and NHibernate. Unfortunately, our UnitOfWork resides in a different .dll and it doesn't have a default empty .ctor. This is what I do to register NHibernate:
var connectionString = ConfigurationManager.ConnectionStrings["jobManagerConnection"].ConnectionString;
var assemblyMap = ConfigurationManager.AppSettings["assemblyMap"];
container
.RegisterType<IUnitOfWork, UnitOfWork>(new ContainerControlledLifetimeManager());
In my WebController I have this:
/// <summary>Gets or sets UnitOfWork.</summary>
[Dependency]
public IUnitOfWork UnitOfWork { get; set; }
The problem is that the constructor of UnitOfWork expects 2 mandatory strings. How I can setup the RegisterType for this Interface in order to pass the two parameters retreived from the web.config? Is it possible?
© Stack Overflow or respective owner