| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | using TeleFlow.Framework.Application; |
| | | 3 | | |
| | | 4 | | namespace TeleFlow.Framework.DependencyInjection; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Registers TeleFlow application lifecycle tasks that execute before and after update source processing. |
| | | 8 | | /// These registration APIs store task types so the runtime can create each task from the correct lifecycle scope. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class ApplicationLifecycleServiceCollectionExtensions |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Registers a startup task that runs before the configured update source starts processing updates. |
| | | 14 | | /// </summary> |
| | | 15 | | public static IServiceCollection AddTeleFlowStartupTask<TTask>(this IServiceCollection services) |
| | | 16 | | where TTask : class, ITeleFlowStartupTask |
| | | 17 | | { |
| | 7 | 18 | | ArgumentNullException.ThrowIfNull(services); |
| | | 19 | | |
| | 7 | 20 | | services.AddSingleton(new TeleFlowStartupTaskRegistration(typeof(TTask))); |
| | 7 | 21 | | return services; |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Registers a shutdown task that runs after the configured update source stops processing updates. |
| | | 26 | | /// </summary> |
| | | 27 | | public static IServiceCollection AddTeleFlowShutdownTask<TTask>(this IServiceCollection services) |
| | | 28 | | where TTask : class, ITeleFlowShutdownTask |
| | | 29 | | { |
| | 8 | 30 | | ArgumentNullException.ThrowIfNull(services); |
| | | 31 | | |
| | 8 | 32 | | services.AddSingleton(new TeleFlowShutdownTaskRegistration(typeof(TTask))); |
| | 8 | 33 | | return services; |
| | | 34 | | } |
| | | 35 | | } |