Ejemplo n.º 1
0
        public IHostBuilder UseServiceProviderFactory <TContainerBuilder>(Func <HostBuilderContext, IServiceProviderFactory <TContainerBuilder> > factory)
            where TContainerBuilder : notnull
        {
            Func <HostBuilderContext> contextResolver = () => this.hostBuilderContext !;

            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            this.serviceProviderFactory = new ServiceFactoryAdapter <TContainerBuilder>(contextResolver, factory);
            return(this);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Overrides the factory used to create the service provider.
 /// </summary>
 /// <param name="factory">A factory used for creating service providers.</param>
 /// <typeparam name="TContainerBuilder">The type of the builder to create.</typeparam>
 /// <returns>The same instance of the <see cref="IHostBuilder"/> for chaining.</returns>
 public IHostBuilder UseServiceProviderFactory <TContainerBuilder>(Func <HostBuilderContext, IServiceProviderFactory <TContainerBuilder> > factory)
 {
     _serviceProviderFactory = new ServiceFactoryAdapter <TContainerBuilder>(() => _hostBuilderContext, factory ?? throw new ArgumentNullException(nameof(factory)));
     return(this);
 }
Ejemplo n.º 3
0
#pragma warning disable CS8714 // The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint.
        public IAppHostBuilder UseServiceProviderFactory <TContainerBuilder>(IServiceProviderFactory <TContainerBuilder> factory)
        {
            _serviceProviderFactory = new ServiceFactoryAdapter <TContainerBuilder>(factory ?? throw new ArgumentNullException(nameof(factory)));
            return(this);
        }
Ejemplo n.º 4
0
 public HostBuilder()
 {
     _serviceProviderFactory = new ServiceFactoryAdapter <IServiceCollection>(new DefaultServiceProviderFactory());
 }