2

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.

1 Answer 1

7
container.RegisterType<IBlabla, Blabla>(new InjectionConstructor("myBinding"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.