问题
I was wondering how do I achieve such a feature in the UnityContainer:
container.RegisterType<IDummy>(Func<IDummy>) // deferred resolution
回答1:
If you're going to register factory instead of instance, try this:
container.RegisterType<IDummy>(new InjectionFactory(context => new Dummy()));
Just replace "context => new Dummy()" with your lambda.
来源:https://stackoverflow.com/questions/24256940/registering-types-with-lambda-expression