DictionaryExtensions¶
Dictionary merge and safe-read/upsert helpers layered on Enforce guards. (BR-082, BR-083, BR-084)
Purpose¶
Context¶
- Namespace:
SAIF.Common.Extensions - Assembly/package:
SAIF.Framework.Common
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| Merge |
public static void Merge<TValue>(this IDictionary instance, IDictionary<string,TValue> source, bool replaceExisting = true) |
Copies every entry from source into instance, optionally skipping keys that already exist. (BR-082) |
| TryGetValue |
public static TValue TryGetValue<TKey,TValue>(this IDictionary<TKey,TValue> instance, TKey key, TValue defaultValue) |
Returns the stored value for key, or defaultValue when the key is absent, never throwing KeyNotFoundException. (BR-039, BR-083) |
| UpdateOrAdd |
public static TValue UpdateOrAdd<TKey,TValue>(this IDictionary<TKey,TValue> instance, TKey key, TValue value) |
Overwrites an existing key or adds a new one, returning value for chaining. (BR-039, BR-084) |
Sources¶
Common/SAIF.Common/Extensions/DictionaryExtensions.cs