public IEnumerable ResolveAll(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException(nameof(serviceType)); } if (resolver == null) { throw new InvalidOperationException("The resolver was not initialized."); } lock (this) { try { return(resolver.ResolveMany <object>(serviceType)); } catch (NullReferenceException) { // this means that the container is out of sync in the dispose return(new object[0]); } catch (ServiceResolutionException) { throw; } catch (Exception ex) { throw new ServiceResolutionException(serviceType, "Error resolving all services", ex); } } }
public IEnumerable <TType> ResolveAll <TType>(string key = null) where TType : class => _resolver.ResolveMany <TType>(serviceKey : ResolveKey(key));
/// <summary>Retrieves a collection of services from the scope or empty collection.</summary> /// <returns>The retrieved collection of services.</returns> /// <param name="serviceType">The collection of services to be retrieved.</param> public IEnumerable <object> GetServices(Type serviceType) => ScopedContainer.ResolveMany(serviceType);
/// <summary> /// Gets all scoped T instances /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> /// <returns></returns> public IEnumerable <T> GetAll <T>(string key = null) => _resolveContext.ResolveMany <T>();