/// <summary> /// Creates a service/component instance from a factory adapter, resolution path and registration.s /// </summary> /// <returns>The created component instance.</returns> /// <param name="factory">The factory adapter from which to create the instance.</param> /// <param name="path">The current resolution path.</param> /// <param name="registration">The registration for the component to be created.</param> public virtual object CreateFromFactory(IFactoryAdapter factory, ResolutionPath path, IServiceRegistration registration) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (!factory.RequiresParameterResolution) { return(factory.Execute(Enumerable.Empty <object>().ToArray())); } var parameters = factory.GetParameters(); var resolvedParameters = parameters .Select(param => ResolveParameter(param, path, registration)) .ToArray(); return(factory.Execute(resolvedParameters)); }
object CreateInstance(IFactoryAdapter adapter, ResolutionPath path, IServiceRegistration registration) => adapter.Execute(new object[0]);