| | | 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.Loading; |
| | | 12 | | #pragma warning restore IDE0130 |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Registers application-wide busy loading services. |
| | | 16 | | /// </summary> |
| | | 17 | | public static class ServiceCollectionExtensions |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Registers a singleton <see cref="BusyService"/> as <see cref="IBusyService"/>. |
| | | 21 | | /// View models use their own local <see cref="BusyService"/> from <see cref="ViewModels.ViewModelBase"/>. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <param name="services">The service collection.</param> |
| | | 24 | | /// <returns>The same service collection for chaining.</returns> |
| | | 25 | | public static IServiceCollection AddBusy(this IServiceCollection services) |
| | | 26 | | { |
| | 12 | 27 | | services.TryAddSingleton<IBusyService, BusyService>(); |
| | | 28 | | |
| | 12 | 29 | | return services; |
| | | 30 | | } |
| | | 31 | | } |
| | | 32 | | |