Implement UpdateCollection to CollectionExtensions;

This commit is contained in:
Loretta 2025-04-11 13:37:29 +02:00
parent 4b540745e0
commit 4f28dd0f26
1 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,17 @@ namespace AyCode.Core.Extensions
{
public static class CollectionExtensions
{
public static void UpdateCollection<TDataItem>(this IList<TDataItem> source, IList<TDataItem> dataItems, bool isRemove) where TDataItem : IId<Guid>
{
if (source == null) throw new ArgumentNullException(nameof(source), $"source == null");
if (dataItems == null) throw new ArgumentNullException(nameof(dataItems), $"dataItems == null");
foreach (var dataItem in dataItems)
{
source.UpdateCollection(dataItem, isRemove);
}
}
public static TrackingState UpdateCollection<TDataItem>(this IList<TDataItem> source, TDataItem dataItem, bool isRemove) where TDataItem : IId<Guid>
{
if (source == null) throw new ArgumentNullException(nameof(source), $"source == null");