Deveel.Data.Services.ServiceContainer.ResolveAll C# (CSharp) Метод

ResolveAll() публичный Метод

public ResolveAll ( Type serviceType ) : IEnumerable
serviceType System.Type
Результат IEnumerable
        public IEnumerable ResolveAll(Type serviceType)
        {
            if (serviceType == null)
                throw new ArgumentNullException("serviceType");

            if (container == null)
                throw new InvalidOperationException("The container was not initialized.");

            lock (this) {
                try {
                    return container.ResolveMany<object>(serviceType);
                } catch (NullReferenceException) {
                    // this means that the container is out of sync in the dispose
                    return new object[0];
                }
            }
        }

Usage Example

Пример #1
0
        public void ResolveAll()
        {
            var provider = new ServiceContainer();

            provider.Register <IService, ServiceOne>();
            provider.Register <IService, ServiceTwo>();

            var services = provider.ResolveAll <IService>();

            Assert.NotNull(services);
            Assert.NotEmpty(services);
            Assert.Equal(2, services.Count());
        }