using System; using System.Collections.Generic; using System.Linq; namespace SuperTiled2Unity { public static class EnumerableExtensions { public static bool IsEmpty(this IEnumerable array) { if (array == null) { return true; } return !array.Any(); } public static Dictionary SafeToDictionary( this IEnumerable source, Func keySelector, Func elementSelector, IEqualityComparer comparer = null) { var dictionary = new Dictionary(comparer); if (source == null) { return dictionary; } foreach (TSource element in source) { dictionary[keySelector(element)] = elementSelector(element); } return dictionary; } } }