c# - Retrieve Injection Members from Unity Container -


i doing dependency injection microsoft.practices.unity.

for classes, using injection factories this:

 container.registertype<icar>(new injectionfactory(o => {return new car("toyota")})); 

later in code, want able find out if have used or not injection factory given interface.

i see can regitrations in container.registrations, these objects not give me injection members.

a possible way them implement wrapper around iunitycontainer, records injection members.

but maybe there better way directly leverages unity api ? there way these injection members directly unity container ?

as suggested in comment (but not unity). copied project.

public void configureservices(iservicecollection services)     {         var lgr = logmanager.getcurrentclasslogger();         var logger = new nloglogger(lgr);          services.addsingleton<ilogger>(provider => logger);         services.addsingleton<imachineconfigfactory, machineconfigfactory>();         services.addsingleton<imemorycacheservice, memorycacheservice>();         services.addsingleton<iservermanagerservice, servermanagerservice>();         services.addsingleton<isubscriberserverhubservice, subscriberserverhubservice>();         services.addsingleton<ipurgeservice, purgeservice>();          var configuration = getconfiguration(option);         services.addsingleton(configuration);          services.addoptions();         services.configure<hostconfig>(configuration.getsection("hostconfig"));          services.addsingleton<servermanager>();         services.addsingleton<cachemanagerservice>();          return services;     } 

and then:

 public class healthchecker : ihealthchecker {     private readonly healthcheckerconfig _config;     private readonly iassetprovider _assetprovider;      public healthchecker(ioptions<healthcheckerconfig> config, iassetprovider assetprovider)     {         _config = config.value;         _assetprovider = assetprovider;     } } 

or missing something?


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -