public static IServiceDefintions AddInstance(this IServiceDefintions services, Lifetime lifetime, Type serviceType, Type implementationType, object implementationInstance, string name = null) { if (implementationInstance == null) { throw new ArgumentNullException(nameof(implementationInstance)); } if (!serviceType.IsInstanceOfType(implementationInstance)) { throw new ArgumentException($"{implementationInstance} is not instance of type {serviceType}"); } services.Add(ServiceDefintions.Define(serviceType, implementationType, lifetime, i => implementationInstance, name)); return(services); }
public static IServiceDefintions Add(this IServiceDefintions services, Lifetime lifetime, Type serviceType, Type implementationType, Func <INamedServiceProvider, object> serviceFactory = null, string name = null) { services.Add(ServiceDefintions.Define(serviceType, implementationType, lifetime, serviceFactory, name)); return(services); }