ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

Differenece between Keyed and Named #140

Closed mcdis closed 6 years ago

mcdis commented 6 years ago

What's difference between registation AsKeyed, AsName? How to use AsName? At this moment I'm using only As Keyed, like:

_this.Configure(_=>_.Export<TToolbar>().AsKeyed<IUiToolbarItem>(_toolbarId.Path));
//...
_this.Localte<IUiToolbarItem>(wthiKey:"abc");
ipjohnson commented 6 years ago

Hi @mcdis

The big difference is that Named has no type associated with it (you look it up by name only no type), where as keyed exports by type with a key associated.

The named methods fit a very specific niche where you are looking for something by name and don't care what type it is (MVVM framework where databind happens at runtime so you don't care what type it is).

ipjohnson commented 6 years ago

I'm going to close this as completed