/// <summary> /// Internal to support testing. Initializes <see cref="IHostedService"/> instances in the service, /// and registers them for their preferred service type /// </summary> internal static void InitializeHostedServices(RegisteredServiceProvider provider, IProtocolEndpoint host) { // Pre-register all services before initializing. This ensures that if one service wishes to reference // another one during initialization, it will be able to safely do so foreach (IHostedService service in provider.GetServices <IHostedService>()) { provider.RegisterSingleService(service.ServiceType, service); } ServiceHost serviceHost = host as ServiceHost; foreach (IHostedService service in provider.GetServices <IHostedService>()) { // Initialize all hosted services, and register them in the service provider for their requested // service type. This ensures that when searching for the ConnectionService you can get it without // searching for an IHostedService of type ConnectionService service.InitializeService(host); IDisposable disposable = service as IDisposable; if (serviceHost != null && disposable != null) { serviceHost.RegisterShutdownTask(async(shutdownParams, shutdownRequestContext) => { disposable.Dispose(); await Task.FromResult(0); }); } } }
public ExtensibleServiceHost(RegisteredServiceProvider provider, ChannelBase protocolChannel) : base(protocolChannel) { Validate.IsNotNull(nameof(provider), provider); provider.RegisterSingleService <IServiceHost>(this); provider.RegisterHostedServices(); // Initialize all hosted services foreach (IHostedService service in provider.GetServices <IHostedService>()) { service.InitializeService(this); } serviceProvider = provider; }
/// <summary> /// Internal to support testing. Initializes <see cref="IHostedService"/> instances in the service, /// and registers them for their preferred service type /// </summary> internal static void InitializeHostedServices(RegisteredServiceProvider provider, IProtocolEndpoint host) { // Pre-register all services before initializing. This ensures that if one service wishes to reference // another one during initialization, it will be able to safely do so foreach (IHostedService service in provider.GetServices <IHostedService>()) { provider.RegisterSingleService(service.ServiceType, service); } foreach (IHostedService service in provider.GetServices <IHostedService>()) { // Initialize all hosted services, and register them in the service provider for their requested // service type. This ensures that when searching for the ConnectionService you can get it without // searching for an IHostedService of type ConnectionService service.InitializeService(host); } }
protected RegisteredServiceProvider CreateProvider() { ServiceProvider = new RegisteredServiceProvider(); return(ServiceProvider); }
public ServiceProviderTests() { provider = new RegisteredServiceProvider(); }
public AzureAuthenticationManagerTest() { resourceManagerMock = new Mock <IAzureResourceManager>(); serviceProvider = new RegisteredServiceProvider(); serviceProvider.RegisterSingleService <IAzureResourceManager>(resourceManagerMock.Object); }