Show / Hide Table of Contents

Class IDictionaryExtensions

Contains extension methods for IDictionary<TKey, TValue>.

Inheritance
object
IDictionaryExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Microsoft.XboxStudios.BotBrain
Assembly: BotBrain.Core.dll
Syntax
public static class IDictionaryExtensions

Methods

View Source

Increment<TKey>(IDictionary<TKey, int>, TKey, int, int)

Increments a dictionary value for a specified key.

Declaration
public static void Increment<TKey>(this IDictionary<TKey, int> self, TKey key, int amount, int defaultValue = 0)
Parameters
Type Name Description
IDictionary<TKey, int> self

The calling dictionary which is being modified.

TKey key

The target key.

int amount

The amount to increment the value by.

int defaultValue

The default value for a non-existent key.

Type Parameters
Name Description
TKey

The type corresponding to the dictionary keys.

View Source

Increment<TKey>(IDictionary<TKey, TimeSpan>, TKey, TimeSpan, TimeSpan)

Increments a dictionary value for a specified key.

Declaration
public static void Increment<TKey>(this IDictionary<TKey, TimeSpan> self, TKey key, TimeSpan amount, TimeSpan defaultValue = default)
Parameters
Type Name Description
IDictionary<TKey, TimeSpan> self

The calling dictionary which is being modified.

TKey key

The target key.

TimeSpan amount

The duration to increment the value by.

TimeSpan defaultValue

The default value for a non-existent key.

Type Parameters
Name Description
TKey

The type corresponding to the dictionary keys.

View Source

Merge<TKey, TValue>(IDictionary<TKey, TValue>, IEnumerable<KeyValuePair<TKey, TValue>>)

Merges a dictionary and an enumerable of key-value pairs together, while not overwriting any key already existing in the dictionary.

Declaration
public static void Merge<TKey, TValue>(this IDictionary<TKey, TValue> self, IEnumerable<KeyValuePair<TKey, TValue>> other)
Parameters
Type Name Description
IDictionary<TKey, TValue> self

The calling dictionary which is being modified.

IEnumerable<KeyValuePair<TKey, TValue>> other

An enumerable of key-value pairs to merge in.

Type Parameters
Name Description
TKey

The type corresponding to the dictionary keys.

TValue

The type corresponding to the dictionary values.

View Source

Modify<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TValue, TValue>, TValue)

Modifies the value of a dictionary entry based on a specified modification function.

Declaration
public static void Modify<TKey, TValue>(this IDictionary<TKey, TValue> self, TKey key, Func<TValue, TValue> modify, TValue defaultValue = default) where TValue : notnull
Parameters
Type Name Description
IDictionary<TKey, TValue> self

The calling dictionary which is being modified.

TKey key

The target key.

Func<TValue, TValue> modify

A function that transforms the current key's value.

TValue defaultValue

The default value for a non-existent key.

Type Parameters
Name Description
TKey

The type corresponding to the dictionary keys.

TValue

The type corresponding to the dictionary values.

  • View Source
In this article
Back to top Generated by DocFX