using System; using System.Collections; using System.Collections.Generic; using System.Data.SqlTypes; using System.Linq; using System.Xml.Schema; namespace Babushka.scripts.CSharp.Common.Util; public static class LinqExtras { public static void ForEach(this IEnumerable self, Action action) { foreach (var t in self) { action.Invoke(t); } } public static T? Random(this IEnumerable self) { var selfList = self.ToList(); if (selfList.Count == 0) return default; if (selfList.Count == 1) return selfList[0]; var randomIndex = new Random().Next(0, selfList.Count); return selfList[randomIndex]; } }