public static ContainerBuilder AddService <TService, TConcrete>(this ContainerBuilder builder, ServiceLifespan lifespan, object instance) { instance = instance ?? throw new ArgumentNullException(nameof(instance)); return(AddService(builder, lifespan, typeof(TService), typeof(TConcrete), null, instance)); }
private static ContainerBuilder AddService <TService, TConcrete>(this ContainerBuilder builder, ServiceLifespan lifespan, Func <IContainerRuntime, TConcrete> factoryMethod) { factoryMethod = factoryMethod ?? throw new ArgumentNullException(nameof(factoryMethod)); return(AddService(builder, lifespan, typeof(TService), typeof(TConcrete), r => factoryMethod(r), null)); }
public static ContainerBuilder AddService(this ContainerBuilder builder, ServiceLifespan lifespan, Type serviceType, Type concreteType, Func <IContainerRuntime, object> factoryMethod, object instance) { builder.RegisterService(new ServiceRegistration { ServiceType = serviceType, ConcreteType = concreteType, ServiceLifespan = lifespan, FactoryMethod = factoryMethod, ServiceInstance = instance }); return(builder); }
public static ContainerBuilder AddService(this ContainerBuilder builder, ServiceLifespan lifespan, Type serviceType, Type concreteType) => AddService(builder, lifespan, serviceType, concreteType, null, null);
public static ContainerBuilder AddService <TService, TConcrete>(this ContainerBuilder builder, ServiceLifespan lifespan) => AddService(builder, lifespan, typeof(TService), typeof(TConcrete), null, null);