| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ItemsProviderBase.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Collections.Generic; |
| | | 8 | | using System.Linq; |
| | | 9 | | using System.Threading; |
| | | 10 | | |
| | | 11 | | namespace MyNet.Primitives.Providers; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Defines an abstract base class for implementing the <see cref="IItemsProvider{T}"/> interface, providing a default i |
| | | 15 | | /// </summary> |
| | | 16 | | /// <typeparam name="T">The type of items provided by the implementing class.</typeparam> |
| | | 17 | | public abstract class ItemsProviderBase<T> : IItemsProvider<T> |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Provides a collection of items of type T. This method must be implemented by derived classes to return the items |
| | | 21 | | /// </summary> |
| | | 22 | | /// <returns>A collection of items of type T.</returns> |
| | | 23 | | public abstract IEnumerable<T> GetItems(); |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Asynchronously retrieves a stream of items of type T by converting the collection provided by the <see cref="Get |
| | | 27 | | /// </summary> |
| | | 28 | | /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param> |
| | | 29 | | /// <returns>An asynchronous stream of items of type T.</returns> |
| | 9 | 30 | | public IAsyncEnumerable<T> GetItemsAsync(CancellationToken cancellationToken = default) => GetItems().ToAsyncEnumera |
| | | 31 | | } |
| | | 32 | | |