| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="CompositeToastFilter.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 MyNet.UI.Notifications.Models; |
| | | 10 | | |
| | | 11 | | namespace MyNet.UI.Toasting.Filters; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Implements a toast filter that combines multiple filters, allowing a notification to be displayed only if it passes |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="filters">The collection of filters to be applied.</param> |
| | | 17 | | public sealed class CompositeToastFilter(IEnumerable<IToastFilter> filters) : IToastFilter |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Determines whether the specified notification should be displayed based on the combined results of all filters. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="notification">The notification to be evaluated.</param> |
| | | 23 | | /// <returns><c>true</c> if the notification should be displayed; otherwise, <c>false</c>.</returns> |
| | 6 | 24 | | public bool ShouldDisplay(INotification notification) => filters.All(f => f.ShouldDisplay(notification)); |
| | | 25 | | } |
| | | 26 | | |