/
aprogrammer
/
reverse-proxy-ms-yarp
Обзор
Документация
Войти
/
aprogrammer
/
reverse-proxy-ms-yarp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Kubernetes.Controller/Hosting/ServiceCollectionHostedServiceAdapterExtensions.cs
31 строка
1 KB
David Bevin
Tidied up namespaces for Kubernetes projects (#1717)
27 май 2022, 18:52
Не верифицирован
27 май 2022, 18:52
2fa9c3b
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.Extensions.Hosting; using System.Linq; using Yarp.Kubernetes.Controller.Hosting; namespace Microsoft.Extensions.DependencyInjection; /// <summary> /// Class ServiceCollectionHostedServiceAdapterExtensions. /// </summary> public static class ServiceCollectionHostedServiceAdapterExtensions { /// <summary> /// Registers the hosted service. /// </summary> /// <typeparam name="TService">The type of the t service.</typeparam> /// <param name="services">The services.</param> /// <returns>IServiceCollection.</returns> public static IServiceCollection RegisterHostedService<TService>(this IServiceCollection services) where TService : IHostedService { if (!services.Any(serviceDescriptor => serviceDescriptor.ServiceType == typeof(HostedServiceAdapter<TService>))) { services = services.AddHostedService<HostedServiceAdapter<TService>>(); } return services; } }