示例#1
0
        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);
                }
            }
        }
示例#2
0
 public IEnumerable <TType> ResolveAll <TType>(string key = null) where TType : class => _resolver.ResolveMany <TType>(serviceKey : ResolveKey(key));
示例#3
0
 /// <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);
示例#4
0
 /// <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>();