public ServiceBuilder RegisterInstance(object instance) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } var item = new ServiceBuilder { ImplementationInstance = instance }; _builders.Add(item); return(item); }
public ServiceBuilder Register(Func <IServiceProvider, object> factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } var item = new ServiceBuilder { ImplementationFactory = factory }; _builders.Add(item); return(item); }
public ServiceBuilder RegisterType(Type implementationType) { if (implementationType == null) { throw new ArgumentNullException(nameof(implementationType)); } var item = new ServiceBuilder { ImplementationType = implementationType }; _builders.Add(item); return(item); }
public static ServiceBuilder As <TService>(this ServiceBuilder builder) { return(builder.As(typeof(TService))); }
public static ServiceBuilder Keyed <TService>(this ServiceBuilder builder, object keyed) { return(builder.Keyed(typeof(TService), keyed)); }
public static ServiceBuilder Keyed(this ServiceBuilder builder, Type serviceType, object keyed) { builder.ServiceKeys.Add(new KeyedServiceKey(serviceType, keyed)); return(builder); }
public static ServiceBuilder Named <TService>(this ServiceBuilder builder, string named) { return(builder.Named(typeof(TService), named)); }
public static ServiceBuilder Named(this ServiceBuilder builder, Type serviceType, string named) { return(builder.Keyed(serviceType, named)); }
public static ServiceBuilder Lifetime(this ServiceBuilder builder, ServiceLifetime lifetime) { builder.Lifetime = lifetime; return(builder); }
public static ServiceBuilder Transient(this ServiceBuilder builder) { return(builder.Lifetime(ServiceLifetime.Transient)); }
public static ServiceBuilder Scoped(this ServiceBuilder builder) { return(builder.Lifetime(ServiceLifetime.Scoped)); }
public static ServiceBuilder Singleton(this ServiceBuilder builder) { return(builder.Lifetime(ServiceLifetime.Singleton)); }
public static ServiceBuilder As(this ServiceBuilder builder, Type serviceType) { builder.ServiceKeys.Add(new ServiceKey(serviceType)); return(builder); }