public object GetService(Type serviceType) { if (!ShouldResolveInstance(serviceType)) { return(SystemActivator.CreateInstance(serviceType)); } object result = null; var container = StashboxScope.GetContainer() ?? RootContainer; try { result = container.Resolve(serviceType); } catch (ResolutionFailedException) { // Nothing. Eat it and continue. } if (result == null) { result = _next?.GetService(serviceType); } if (result != null) { return(result); } if ((result = SystemActivator.CreateInstance(serviceType)) != null && TrackUnresolvableTypes && _unresolvableTypes.Count < MaxUnresolvableTypes) { _unresolvableTypes.TryAdd(serviceType, true); } return(result); }
public static IStashboxContainer GetStashboxContainer(this HttpContext httpContext) => StashboxScope.GetContainer();