dadhi / DryIoc

DryIoc is fast, small, full-featured IoC Container for .NET
MIT License
1.03k stars 122 forks source link

Probably add the IDictionary<TServiceKey, TService> wrapper #504

Closed dadhi closed 2 years ago

dadhi commented 2 years ago

The implementation is trivial, just inject the IEnumerable<KeyValuePair<TServiceKey, Value>> and call ToDictionary. Previously there was a doubt to add the wrapper because it may be not obvious if dictionary is referring to service keys or to the metadata. Now I am more sure of that because the service keys are unique keys but the metadata may be not.

Side fact, in some programming languages e.g. Scala the standard Map data structure implements the Func<Key, Value> interface, so adding the Dictionary from key to service will provide the shortest migration path from IoC libs which have a specific treatment of Func as Func<Key, Service>.