| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ServiceCollectionExtensions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using Microsoft.Extensions.DependencyInjection; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 9 | | |
| | | 10 | | #pragma warning disable IDE0130 |
| | | 11 | | namespace MyNet.UI.Threading; |
| | | 12 | | #pragma warning restore IDE0130 |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Extension methods for registering threading services. |
| | | 16 | | /// </summary> |
| | | 17 | | public static class ServiceCollectionExtensions |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Registers the default <see cref="ISchedulerProvider"/> when none is already registered. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="services">Service collection.</param> |
| | | 23 | | /// <returns>The same service collection for chaining.</returns> |
| | | 24 | | public static IServiceCollection AddSchedulerProvider(this IServiceCollection services) |
| | | 25 | | { |
| | 33 | 26 | | services.TryAddSingleton<ISchedulerProvider, DefaultSchedulerProvider>(); |
| | 33 | 27 | | return services; |
| | | 28 | | } |
| | | 29 | | } |
| | | 30 | | |