using System; using System.Linq; using System.Collections.Generic; namespace Octokit { internal static class CollectionExtensions { public static TValue SafeGet(this IReadOnlyDictionary dictionary, TKey key) { Ensure.ArgumentNotNull(dictionary, nameof(dictionary)); TValue value; return dictionary.TryGetValue(key, out value) ? value : default(TValue); } public static IList Clone(this IReadOnlyList input) { if (input == null) return null; return input.Select(item => new string(item.ToCharArray())).ToList(); } public static IDictionary Clone(this IReadOnlyDictionary input) { if (input == null) return null; return input.ToDictionary(item => new string(item.Key.ToCharArray()), item => new Uri(item.Value.ToString())); } } }