I assume this is a fixed list. The easiest way is with the provider:
public class MyProvider : IProvider { public object Create(IContext context) { return new Dictionary<string, IMyInterface>{ {"alpha", context.Kernel.Get<ImpClassOne>()}, {"beta", context.Kernel.Get<ImplClassTwo>()} } } public Type Type { get { return typeof(IDictionary<string, IMyInterface>); } } }
You can register the provider in your kernel, for example:
kernel.Bind<IDictionary<string, IMyInterface>>().ToProvider<MyProvider>();
and then [Inject] for the property will use the provider to create the dictionary.
ryber source share