asp.net mvc - Should IDependencyResolver.GetServices using Unity return the default (unnamed) registration -


i've question implementation of mvc's idependencyresolver.getservices when using unity dependency injection.

there several example implementations found, of have been implemented work around problem of unity throwing exceptions when trying resolve unregistered types.

usualy getservices implemented this:

ienumerable<object> idependencyresolver.getservices(type servicetype) {     try     {         return _container.resolveall(servicetype);     }     catch     {         return new list<object>();     } } 

what of concern me, , have been unable find confirmation either way, resolveall not return default (unnamed) registration. see here.

the documentation idependencyresolver not make same statement.

does know whether idependencyresolver.getservices should return registered instances or named instances (using unity parlance)?

try below code. hope work.

return (servicetype.isclass && !servicetype.isabstract) ||        _container.isregistered(servicetype) ? _container.resolveall(servicetype) : new object[] {}; 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -