Reputation: 10983
Suppose I have an interface called IBlabla
, and its implemntation Blabla
, like this :
public class Blabla : IBlabla
{
Blabla(string endPoint) { }
}
Using StructureMap, I can easily inject a parameter to my constructor arguments, like this :
For<IBlabla>().Singleton().Use(() => new Blabla("myBinding"));
How can I acheive this using Unity
?
I have already tried all this :
container.RegisterType<IBlabla>(new HierarchicalLifetimeManager(), new InjectionFactory((x, t, c) => new Blabla("myBinding")));
container.RegisterType<IBlabla, Blabla>(new InjectionConstructor(new ResolvedParameter<string>("myBinding")));
But none of them worked for me.
Upvotes: 2
Views: 2828
Reputation: 1522
container.RegisterType<IBlabla, Blabla>(new InjectionConstructor("myBinding"));
Upvotes: 7