using System;
using System.Collections.Generic;

namespace Quadarax.Foundation.Core.Value.Extensions
{
    public static class ListExt
    {
        public static void Setup<TItem>(this IList<TItem> owner, IEnumerable<TItem> newItems)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));
            if (newItems == null)
                throw new ArgumentNullException(nameof(newItems));

            owner.Clear();
            owner.AddRange(newItems);

        }

        public static void AddRange<TItem>(this IList<TItem> owner, IEnumerable<TItem> items)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));
            if (items == null)
                throw new ArgumentNullException(nameof(items));

            foreach (var item in items)
                owner.Add(item);
        }
    }
}
