예제 #1
0
 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);
 }
예제 #2
0
 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);
 }