public IEnumerable <object> GetServices(Type serviceType) { if (IsRegistered(serviceType)) { yield return(ChildContainer.Resolve(serviceType)); } foreach (var service in ChildContainer.ResolveAll(serviceType)) { yield return(service); } }
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); }
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); }
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); }