Table of Contents

Class DictionaryExtensions

Namespace
FoundationaLLM.Common.Extensions
Assembly
FoundationaLLM.Common.dll

Provides extension methods for Dictionary<TKey, TValue>.

public static class DictionaryExtensions
Inheritance
DictionaryExtensions
Inherited Members

Methods

FilterKeys(Dictionary<string, object>, string)

Filters the keys of a dictionary based on a specified namespace.

public static Dictionary<string, object> FilterKeys(this Dictionary<string, object> source, string keyNamespace)

Parameters

source Dictionary<string, object>

The dictionary to be filtered.

keyNamespace string

The namespace of the keys to be returned in the resulting dictionary.

Returns

Dictionary<string, object>

A new dictionary that contains the keys (and their values) which start with the provided namespace string.

ToObject<T>(Dictionary<string, object>, Dictionary<string, object>?)

Converts a dictionary to an object of type T with optional overrides.

public static T ToObject<T>(this Dictionary<string, object> source, Dictionary<string, object>? overrides = null) where T : new()

Parameters

source Dictionary<string, object>

The source properties for the returned object.

overrides Dictionary<string, object>

Optional overrides to apply to the returned object parameters.

Returns

T

Type Parameters

T

The type of the object to which you want to convert from a source dictionary.