2 instantiations of HostBuilderContext
Microsoft.Extensions.Hosting (2)
HostApplicationBuilder.cs (1)
168hostBuilderContext = new HostBuilderContext(new Dictionary<object, object>())
HostBuilder.cs (1)
269_hostBuilderContext = new HostBuilderContext(Properties)
88 references to HostBuilderContext
Microsoft.AspNetCore (17)
BootstrapHostBuilder.cs (10)
17private readonly List<Action<HostBuilderContext, IConfigurationBuilder>> _configureAppActions = new(); 18private readonly List<Action<HostBuilderContext, IServiceCollection>> _configureServicesActions = new(); 26if (descriptor.ServiceType == typeof(HostBuilderContext)) 28Context = (HostBuilderContext)descriptor.ImplementationInstance!; 35throw new InvalidOperationException($"{nameof(HostBuilderContext)} must exist in the {nameof(IServiceCollection)}"); 41public HostBuilderContext Context { get; } 49public IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate) 55public IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate) 67public IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate) 79public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory) where TContainerBuilder : notnull
ConfigureHostBuilder.cs (7)
20private readonly HostBuilderContext _context; 22private readonly List<Action<HostBuilderContext, object>> _configureContainerActions = new(); 26HostBuilderContext context, 44public IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate) 52public IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate) 95public IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate) 112public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory) where TContainerBuilder : notnull
Microsoft.AspNetCore.Hosting (6)
GenericHost\GenericWebHostBuilder.cs (5)
98private void ScanAssemblyAndRegisterStartup(HostBuilderContext context, IServiceCollection services, WebHostBuilderContext webhostContext, WebHostOptions webHostOptions) 201void ConfigureStartup(HostBuilderContext context, IServiceCollection services) 215private void UseStartup([DynamicallyAccessedMembers(StartupLinkerOptions.Accessibility)] Type startupType, HostBuilderContext context, IServiceCollection services, object? instance = null) 291var actionType = typeof(Action<,>).MakeGenericType(typeof(HostBuilderContext), containerType); 305private void ConfigureContainerImpl<TContainer>(HostBuilderContext context, TContainer container) where TContainer : notnull
GenericHost\WebHostBuilderBase.cs (1)
74protected WebHostBuilderContext GetWebHostBuilderContext(HostBuilderContext context)
Microsoft.AspNetCore.Mvc.Testing (4)
DeferredHostBuilder.cs (4)
56public IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate) 62public IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate) 77public IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate) 89public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory) where TContainerBuilder : notnull
Microsoft.AspNetCore.Tests (1)
WebApplicationTests.cs (1)
2421Assert.Contains(builder.Services, service => service.ServiceType == typeof(HostBuilderContext));
Microsoft.Extensions.Hosting (40)
HostApplicationBuilder.cs (10)
22private readonly HostBuilderContext _hostBuilderContext; 136private void Initialize(HostApplicationBuilderSettings settings, out HostBuilderContext hostBuilderContext, out IHostEnvironment environment, out LoggingBuilder logging, out MetricsBuilder metrics) 259private readonly List<Action<HostBuilderContext, IConfigurationBuilder>> _configureAppConfigActions = new(); 261private readonly List<Action<HostBuilderContext, IServiceCollection>> _configureServicesActions = new(); 306foreach (Action<HostBuilderContext, IConfigurationBuilder> configureAppAction in _configureAppConfigActions) 310foreach (Action<HostBuilderContext, IServiceCollection> configureServicesAction in _configureServicesActions) 352public IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate) 360public IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate) 377public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory) where TContainerBuilder : notnull 385public IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate)
HostBuilder.cs (13)
29private readonly List<Action<HostBuilderContext, IConfigurationBuilder>> _configureAppConfigActions = new List<Action<HostBuilderContext, IConfigurationBuilder>>(); 30private readonly List<Action<HostBuilderContext, IServiceCollection>> _configureServicesActions = new List<Action<HostBuilderContext, IServiceCollection>>(); 36private HostBuilderContext? _hostBuilderContext; 73/// the results will be additive. The results will be available at <see cref="HostBuilderContext.Configuration"/> for 79public IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate) 93public IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate) 122public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory) where TContainerBuilder : notnull 139public IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate) 283foreach (Action<HostBuilderContext, IConfigurationBuilder> buildAction in _configureAppConfigActions) 294HostBuilderContext hostBuilderContext, 346foreach (Action<HostBuilderContext, IServiceCollection> configureServicesAction in _configureServicesActions)
HostingHostBuilderExtensions.cs (9)
82public static IHostBuilder UseDefaultServiceProvider(this IHostBuilder hostBuilder, Action<HostBuilderContext, ServiceProviderOptions> configure) 98public static IHostBuilder ConfigureLogging(this IHostBuilder hostBuilder, Action<HostBuilderContext, ILoggingBuilder> configureLogging) 120public static IHostBuilder ConfigureHostOptions(this IHostBuilder hostBuilder, Action<HostBuilderContext, HostOptions> configureOptions) 139/// the results will be additive. The results will be available at <see cref="HostBuilderContext.Configuration"/> for 236internal static void ApplyDefaultAppConfiguration(HostBuilderContext hostingContext, IConfigurationBuilder appConfigBuilder, string[]? args) 262static bool GetReloadConfigOnChangeValue(HostBuilderContext hostingContext) => hostingContext.Configuration.GetValue("hostBuilder:reloadConfigOnChange", defaultValue: true); 273internal static void AddDefaultServices(HostBuilderContext hostingContext, IServiceCollection services) 325internal static ServiceProviderOptions CreateDefaultServiceProviderOptions(HostBuilderContext context) 418public static IHostBuilder ConfigureMetrics(this IHostBuilder hostBuilder, Action<HostBuilderContext, IMetricsBuilder> configureMetrics)
Internal\ConfigureContainerAdapter.cs (3)
10private readonly Action<HostBuilderContext, TContainerBuilder> _action; 12public ConfigureContainerAdapter(Action<HostBuilderContext, TContainerBuilder> action) 19public void ConfigureContainer(HostBuilderContext hostContext, object containerBuilder)
Internal\IConfigureContainerAdapter.cs (1)
8void ConfigureContainer(HostBuilderContext hostContext, object containerBuilder);
Internal\ServiceFactoryAdapter.cs (4)
13private readonly Func<HostBuilderContext>? _contextResolver; 14private readonly Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>>? _factoryResolver; 23public ServiceFactoryAdapter(Func<HostBuilderContext> contextResolver, Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factoryResolver)
Microsoft.Extensions.Hosting.Abstractions (7)
HostBuilderContext.cs (1)
16/// Initializes a new instance of <see cref="HostBuilderContext"/>.
IHost.cs (1)
16/// Gets the services configured for the program (for example, using <see cref="IHostBuilder.ConfigureServices(Action{HostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection})" />).
IHostBuilder.cs (5)
32/// the results will be additive. The results will be available at <see cref="HostBuilderContext.Configuration"/> for 38IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate); 46IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate); 62IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory) where TContainerBuilder : notnull; 71IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate);
Microsoft.Extensions.Hosting.Systemd (1)
SystemdHostBuilderExtensions.cs (1)
65/// <see cref="IHostBuilder.ConfigureServices(System.Action{HostBuilderContext, IServiceCollection})"/> callback.
Microsoft.Extensions.Hosting.Testing (4)
FakeHostBuilder.cs (4)
67public IHostBuilder ConfigureAppConfiguration(Action<HostBuilderContext, IConfigurationBuilder> configureDelegate) 72public IHostBuilder ConfigureServices(Action<HostBuilderContext, IServiceCollection> configureDelegate) 83public IHostBuilder UseServiceProviderFactory<TContainerBuilder>(Func<HostBuilderContext, IServiceProviderFactory<TContainerBuilder>> factory) 89public IHostBuilder ConfigureContainer<TContainerBuilder>(Action<HostBuilderContext, TContainerBuilder> configureDelegate) => _builder.ConfigureContainer(configureDelegate);
Microsoft.Extensions.Hosting.Testing.Tests (6)
FakeHostBuilderTests.cs (3)
75var configurationDelegate = (HostBuilderContext _, IConfigurationBuilder _) => { }; 101var configurationDelegate = (HostBuilderContext _, object _) => { }; 193var functor = (HostBuilderContext _) => factory;
HostingFakesExtensionsTests.cs (3)
118.Setup(x => x.ConfigureAppConfiguration(It.IsAny<Action<HostBuilderContext, IConfigurationBuilder>>())) 337.Setup(x => x.ConfigureAppConfiguration(It.IsAny<Action<HostBuilderContext, IConfigurationBuilder>>())) 339.Callback<Action<HostBuilderContext?, IConfigurationBuilder>>(configure => configure(null, appConfigBuilder));
Microsoft.Extensions.Hosting.WindowsServices (2)
WindowsServiceLifetimeHostBuilderExtensions.cs (2)
72/// <see cref="IHostBuilder.ConfigureServices(Action{HostBuilderContext, IServiceCollection})"/> callback. 91/// <see cref="IHostBuilder.ConfigureServices(Action{HostBuilderContext, IServiceCollection})"/> callback.