/// <inheritdoc /> public object GetService([NotNull] Type serviceType) { if (ResolvedDependencies.TryGetValue(serviceType, out var foundService)) { return(foundService); } var thisType = typeof(IntersectServiceDependencyResolver); var definitionType = serviceType; if (serviceType.IsAbstract || serviceType.IsInterface) { definitionType = Assembly.GetAssembly(thisType) ?.DefinedTypes ?.Where(typeInfo => typeInfo?.Namespace?.StartsWith(thisType.Namespace ?? "") ?? false) .FirstOrDefault(typeInfo => serviceType.IsAssignableFrom(typeInfo.AsType())); } var constructor = definitionType?.GetConstructor(new[] { typeof(ApiConfiguration), typeof(HttpConfiguration) }); var constructedService = constructor?.Invoke(new object[] { ApiConfiguration, HttpConfiguration }); ResolvedDependencies[serviceType] = constructedService; return(constructedService); }
/// <inheritdoc /> public void Dispose() { ResolvedDependencies.Clear(); }