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);
        }
Ejemplo n.º 4
0
 public static ServiceBuilder As <TService>(this ServiceBuilder builder)
 {
     return(builder.As(typeof(TService)));
 }
Ejemplo n.º 5
0
 public static ServiceBuilder Keyed <TService>(this ServiceBuilder builder, object keyed)
 {
     return(builder.Keyed(typeof(TService), keyed));
 }
Ejemplo n.º 6
0
 public static ServiceBuilder Keyed(this ServiceBuilder builder, Type serviceType, object keyed)
 {
     builder.ServiceKeys.Add(new KeyedServiceKey(serviceType, keyed));
     return(builder);
 }
Ejemplo n.º 7
0
 public static ServiceBuilder Named <TService>(this ServiceBuilder builder, string named)
 {
     return(builder.Named(typeof(TService), named));
 }
Ejemplo n.º 8
0
 public static ServiceBuilder Named(this ServiceBuilder builder, Type serviceType, string named)
 {
     return(builder.Keyed(serviceType, named));
 }
Ejemplo n.º 9
0
 public static ServiceBuilder Lifetime(this ServiceBuilder builder, ServiceLifetime lifetime)
 {
     builder.Lifetime = lifetime;
     return(builder);
 }
Ejemplo n.º 10
0
 public static ServiceBuilder Transient(this ServiceBuilder builder)
 {
     return(builder.Lifetime(ServiceLifetime.Transient));
 }
Ejemplo n.º 11
0
 public static ServiceBuilder Scoped(this ServiceBuilder builder)
 {
     return(builder.Lifetime(ServiceLifetime.Scoped));
 }
Ejemplo n.º 12
0
 public static ServiceBuilder Singleton(this ServiceBuilder builder)
 {
     return(builder.Lifetime(ServiceLifetime.Singleton));
 }
Ejemplo n.º 13
0
 public static ServiceBuilder As(this ServiceBuilder builder, Type serviceType)
 {
     builder.ServiceKeys.Add(new ServiceKey(serviceType));
     return(builder);
 }