protected object ResolveScopedDependency(DependencyInfo dependency) { if (DependencyScope.Transient == dependency.Scope || null == dependency.Instance) { try { var constructorDependencies = ResolveConstructorParams(dependency); var concretion = Activator.CreateInstance(dependency.Implementation, constructorDependencies.ToArray()); dependency.Instance = concretion; } catch (DependencyException ex) { throw new DependencyException($"Error resolving {dependency.Contract.Name}, some constructor parameters failed to resolve. See inner exception for further details.", ex); } } return(dependency.Instance); }
protected IEnumerable <object> ResolveConstructorParams(DependencyInfo dependency) { var ctor = dependency.Implementation.GetConstructors().First(); return(ctor.GetParameters().Select(parameter => ResolveImplementation(parameter.ParameterType))); }