=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===

This commit is contained in:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
+4
View File
@@ -3,6 +3,7 @@
/// <summary>
/// Provides static extension methods to augment the functionality of dictionary types.
/// </summary>
/// <!-- aidoc:v1 sig=02a7d52 -->
public static class DictionaryEx
{
/// <summary>
@@ -12,6 +13,7 @@ public static class DictionaryEx
/// <param name="key">The key whose associated value should be returned.</param>
/// <param name="defaultValue">The value to return when the key is not present in the dictionary. Defaults to the default value of <typeparamref name="TV"/>.</param>
/// <returns>The value associated with the key if found; otherwise, <paramref name="defaultValue"/>.</returns>
/// <!-- aidoc:v1 sig=b234e0b body=dba24e5 -->
public static TV? GetValue<TK, TV>(this IDictionary<TK, TV> dict, TK key, TV? defaultValue = default)
{
return dict.TryGetValue(key, out var value) ? value : defaultValue;
@@ -24,6 +26,7 @@ public static class DictionaryEx
/// <param name="itemSeparator">The separator placed between each formatted key-value pair in the resulting string.</param>
/// <param name="keySeparator">The separator placed between a key and its corresponding value within each pair.</param>
/// <returns>A single string containing all dictionary entries formatted and joined using the specified separators.</returns>
/// <!-- aidoc:v1 sig=8568016 body=8f9bb50 -->
public static string ToListString<TK, TV>(this IDictionary<TK, TV> dict, string itemSeparator = ", ",
string keySeparator = ": ")
{
@@ -38,6 +41,7 @@ public static class DictionaryEx
/// <param name="dictionary">The dictionary to search for the key.</param>
/// <param name="key">The key whose associated value should be retrieved.</param>
/// <returns>The value associated with the key, or null if the key was not found in the dictionary.</returns>
/// <!-- aidoc:v1 sig=9a17711 body=7e00219 -->
public static TValue? TryGetAndReturn<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
where TKey : notnull where TValue : class
{