Skip to content

DictionaryExtensions

Dictionary merge and safe-read/upsert helpers layered on Enforce guards. (BR-082, BR-083, BR-084)

Purpose

  • Dictionary merge and safe-read/upsert helpers layered on Enforce guards. (BR-082, BR-083, BR-084)

Context

  • Namespace: SAIF.Common.Extensions
  • Assembly/package: SAIF.Framework.Common

Public members

Member Signature Purpose
Merge(this IDictionary instance, IDictionary source, bool replaceExisting = true) 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(this IDictionary instance, TKey key, TValue defaultValue) 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(this IDictionary instance, TKey key, TValue value) 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