namespace EasyLayoutNS.Extensions { using System; using System.Collections.Generic; /// /// Extensions. /// public static class EasyLayoutExtensions { /// /// Is enum value has specified flag? /// /// Enum value. /// Flag. /// true if enum has flag; otherwise false. public static bool IsSet(this ResizeType value, ResizeType flag) { return (value & flag) == flag; } /// /// Convert the specified input with converter. /// /// Input. /// Converter. /// The 1st type parameter. /// The 2nd type parameter. /// List with converted items. public static List Convert(this List input, Converter converter) { #if NETFX_CORE var output = new List(input.Count); for (int i = 0; i < input.Count; i++) { output.Add(converter(input[i])); } return output; #else return input.ConvertAll(converter); #endif } /// /// Apply for each item in the list. /// /// List. /// Action. /// The 1st type parameter. public static void ForEach(this List source, Action action) { foreach (T element in source) { action(element); } } /// /// Apply for each item in the list. /// /// List. /// Action. /// The 1st type parameter. public static void ForEach(this T[] source, Action action) { foreach (T element in source) { action(element); } } #if NETFX_CORE /// /// Apply for each item in the list. /// /// Input. /// Action. /// The 1st type parameter. public static void ForEach(this List list, Action action) { for (int i = 0; i < list.Count; i++) { action(list[i]); } } #endif } }