| | 1 | | namespace MoreStructures.Utilities; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// Extension methods for value readonly collections defined in <see cref="Utilities"/>. |
| | 5 | | /// </summary> |
| | 6 | | public static class ValueReadOnlyCollectionsExtensions |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Builds a <see cref="ValueReadOnlyCollection{T}"/> out of the provided dictionary. |
| | 10 | | /// </summary> |
| | 11 | | /// <typeparam name="T"> |
| | 12 | | /// <inheritdoc cref="ValueReadOnlyCollection{T}" path="/typeparam[@name='T']"/> |
| | 13 | | /// </typeparam> |
| | 14 | | /// <param name="enumerable"> |
| | 15 | | /// <inheritdoc cref="ValueReadOnlyCollection{T}.ValueReadOnlyCollection(IEnumerable{T})" |
| | 16 | | /// path="/param[@name='enumerable']"/> |
| | 17 | | /// </param> |
| | 18 | | /// <returns> |
| | 19 | | /// An instance of <see cref="ValueReadOnlyCollection{T}"/>, independent from the provided enumerable. |
| | 20 | | /// </returns> |
| | 21 | | public static ValueReadOnlyCollection<T> ToValueReadOnlyCollection<T>( |
| | 22 | | this IEnumerable<T> enumerable) |
| | 23 | | where T : notnull => |
| 1569 | 24 | | new(enumerable); |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// Builds a <see cref="ValueReadOnlyDictionary{TKey, TValue}"/> out of the provided dictionary. |
| | 28 | | /// </summary> |
| | 29 | | /// <typeparam name="TKey"> |
| | 30 | | /// <inheritdoc cref="ValueReadOnlyDictionary{TKey, TValue}" path="/typeparam[@name='TKey']"/> |
| | 31 | | /// </typeparam> |
| | 32 | | /// <typeparam name="TValue"> |
| | 33 | | /// <inheritdoc cref="ValueReadOnlyDictionary{TKey, TValue}" path="/typeparam[@name='TValue']"/> |
| | 34 | | /// </typeparam> |
| | 35 | | /// <param name="dictionary"> |
| | 36 | | /// <inheritdoc cref="ValueReadOnlyDictionary{TKey, TValue}.ValueReadOnlyDictionary(IDictionary{TKey, TValue})" |
| | 37 | | /// path="/param[@name='dictionary']"/> |
| | 38 | | /// </param> |
| | 39 | | /// <returns> |
| | 40 | | /// An instance of <see cref="ValueReadOnlyDictionary{TKey, TValue}"/>, independent from the provided dictionary. |
| | 41 | | /// </returns> |
| | 42 | | public static ValueReadOnlyDictionary<TKey, TValue> ToValueReadOnlyDictionary<TKey, TValue>( |
| | 43 | | this IDictionary<TKey, TValue> dictionary) |
| | 44 | | where TKey: notnull |
| | 45 | | where TValue: notnull => |
| 104964 | 46 | | new(dictionary); |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// Builds a <see cref="ValueReadOnlyDictionary{TKey, TValue}"/> out of the provided enumerable of entries. |
| | 50 | | /// </summary> |
| | 51 | | /// <typeparam name="TKey"> |
| | 52 | | /// <inheritdoc cref="ValueReadOnlyDictionary{TKey, TValue}" path="/typeparam[@name='TKey']"/> |
| | 53 | | /// </typeparam> |
| | 54 | | /// <typeparam name="TValue"> |
| | 55 | | /// <inheritdoc cref="ValueReadOnlyDictionary{TKey, TValue}" path="/typeparam[@name='TValue']"/> |
| | 56 | | /// </typeparam> |
| | 57 | | /// <param name="entries"> |
| | 58 | | /// <inheritdoc |
| | 59 | | /// cref="ValueReadOnlyDictionary{TKey, TValue}.ValueReadOnlyDictionary(IEnumerable{KeyValuePair{TKey, TValu |
| | 60 | | /// path="/param[@name='entries']"/> |
| | 61 | | /// </param> |
| | 62 | | /// <returns> |
| | 63 | | /// An instance of <see cref="ValueReadOnlyDictionary{TKey, TValue}"/>, independent from the provided enumerable |
| | 64 | | /// of entries. |
| | 65 | | /// </returns> |
| | 66 | | public static ValueReadOnlyDictionary<TKey, TValue> ToValueReadOnlyDictionary<TKey, TValue>( |
| | 67 | | this IEnumerable<KeyValuePair<TKey, TValue>> entries) |
| | 68 | | where TKey : notnull |
| | 69 | | where TValue : notnull => |
| 1 | 70 | | new(entries); |
| | 71 | | } |