| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using JetBrains.Annotations; |
| | | 4 | | using WireMock.Validation; |
| | | 5 | | |
| | | 6 | | namespace WireMock.Util |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Some IDictionary Extensions |
| | | 10 | | /// </summary> |
| | | 11 | | public static class DictionaryExtensions |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Loops the dictionary and executes the specified action. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <typeparam name="TKey">The type of the key.</typeparam> |
| | | 17 | | /// <typeparam name="TValue">The type of the value.</typeparam> |
| | | 18 | | /// <param name="dictionary">The dictionary to loop (can be null).</param> |
| | | 19 | | /// <param name="action">The action.</param> |
| | | 20 | | public static void Loop<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, [NotNull] Action<TKey, TValue> |
| | 0 | 21 | | { |
| | 0 | 22 | | Check.NotNull(action, nameof(action)); |
| | | 23 | | |
| | 0 | 24 | | if (dictionary != null) |
| | 0 | 25 | | { |
| | 0 | 26 | | foreach (var entry in dictionary) |
| | 0 | 27 | | { |
| | 0 | 28 | | action(entry.Key, entry.Value); |
| | 0 | 29 | | } |
| | 0 | 30 | | } |
| | 0 | 31 | | } |
| | | 32 | | } |
| | | 33 | | } |