public IEnumerable <object> GetServices(Type serviceType)
 {
     if (IsRegistered(serviceType))
     {
         yield return(ChildContainer.Resolve(serviceType));
     }
     foreach (var service in ChildContainer.ResolveAll(serviceType))
     {
         yield return(service);
     }
 }
示例#2
0
 public TestableTestRunner(IScenario specification)
     : base(new StubConfig(), Substitute.For <IDependencyResolver>(),
            Substitute.For <ITestEngine>())
 {
     _specification = specification;
     ChildContainer = Substitute.For <IContainer>();
     DependencyResolver
     .CreateChildContainer()
     .Returns(ChildContainer);
     ChildContainer
     .Resolve(Arg.Any <Type>())
     .Returns(_specification);
 }
示例#3
0
        public object GetService(Type serviceType)
        {
            if (serviceType.Name == "HelpController")
            {
                return(null);
            }
            if (typeof(IController).IsAssignableFrom(serviceType))
            {
                return(ChildContainer.Resolve(serviceType));
            }

            return(IsRegistered(serviceType) ? ChildContainer.Resolve(serviceType) : null);
        }
示例#4
0
        public object GetService(Type serviceType)
        {
            if (typeof(IController).IsAssignableFrom(serviceType))
            {
                try
                {
                    return(ChildContainer.Resolve(serviceType));
                }
                catch {
                    return(null);
                }
            }

            return(IsRegistered(serviceType) ? ChildContainer.Resolve(serviceType) : null);
        }
        /// <summary>
        /// GetService / Resolve by <see cref="Type"/>
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        /// <exception cref="Exception">Cannot resolve.</exception>
        public object GetService(Type serviceType)
        {
            try
            {
                if (typeof(IController).IsAssignableFrom(serviceType))
                {
                    return(ChildContainer.Resolve(serviceType));
                }

                return(IsRegistered(serviceType) ? ChildContainer.Resolve(serviceType) : null);
            }
            catch (Exception ex)
            {
                DebugWriteException(ex);
                throw;
            }
        }
 public object GetService(Type serviceType)
 {
     return(IsRegistered(serviceType) ? ChildContainer.Resolve(serviceType) : null);
 }