using System.Collections; namespace GSS2.Core.Extentions; public static class EnumerableExtensions { public static IEnumerable<(int i, T value)> Enumerate(this IEnumerable values) => values.Select((value, i) => (i, value)); public static string ToString(this IDictionary values, string separator, int indent) => string.Join(separator, values.Select(v => $"{new string(' ', indent)} {v.Key}: {v.Value}")); public static string ToString(this IDictionary values, string separator, int indent) { var strs = new List(); var enumerator = values.GetEnumerator(); while (enumerator.MoveNext()) strs.Add($"{enumerator.Key}: {enumerator.Value}"); return string.Join(separator, strs.Select(s => $"{new string(' ', indent)}{s}")); } public static string ToString(this IEnumerable values, string separator, int indent) => (values as IEnumerable).ToString(separator, indent); public static string ToString(this IEnumerable values, string separator, int indent) { var strs = new List(); var enumerator = values.GetEnumerator(); while (enumerator.MoveNext()) strs.Add(enumerator.Current.ToString()); return string.Join(separator, strs.Select(s => $"{new string(' ', indent)}{s}")); } }