Quantcast
Channel: CommonServiceLocator
Viewing all articles
Browse latest Browse all 118

Created Issue: Provide a new method GetInstanceType(String key) to return the 'MappedToType' associated with a specified key. [14336]

$
0
0
Provide a new method GetInstanceType<>(String key) to return the 'MappedToType' associated with a specified key.

Brief:
In unity, the names: "RegisteredType" and "MappedToType" refer to properties for each registration within the IUnityContainer.Registrations collection.
The names are synonymous with the common: Register<FromType, ToType>
I would imagine all DI containers to have similar functionality.

Scenario:
I have multiple registrations sharing the same "RegisteredType", each with a specific key. If I only have the "RegisteredType" and a key, I would like to get the MappedToType Type object.

Use Case:
In the dictionary below, the key (Type) would be MappedToType objects.
Dictionary<Type, RegisteredType> _Store;

I want to determine if _Store contains the type associated with the specific RegisteredType / service location key. Hence a method like GetInstanceType<From>(String key) would be of value. I don't necessarily want to flat out go and resolve a new instance if I already have it in _Store.

Currently, there is no was to do this without having the service locator / provider resolve an instance.

Viewing all articles
Browse latest Browse all 118

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>