// Author: Gockner, Simon // Created: 2020-11-20 // Copyright(c) 2020 SimonG. All Rights Reserved. using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; namespace Lib.Tools { public static class Enumerables { public static ObservableCollection ToObservableCollection(this IEnumerable enumerable) => new ObservableCollection(enumerable); public static ObservableCollection ToObservableCollectionOfType(this IEnumerable enumerable) => enumerable.Cast().ToObservableCollection(); public static IEnumerable ForEach(this IEnumerable enumerable, Action action) { IEnumerable list = enumerable.ToList(); foreach (T item in list) action(item); return list; } } }