using System.Collections.Generic; namespace ESCPOS_NET.Extensions { public static class Util { /// /// Adds to the list of T items and/or enumerables of T. All other types will be ignored and not added to the list. /// /// List's items type. /// List to be added the items. /// Items to be added. /// True if no item was ignored, otherwise False. public static bool AddRange(this List list, params object[] items) { bool ignoredItems = false; foreach (var item in items) { if (item is T itemT) { list.Add(itemT); } else if (item is IEnumerable arrayT) { list.AddRange(arrayT); } else { ignoredItems = true; } } return !ignoredItems; } } }