Table of Contents

Class DerivedDictionary<TKey, TValue>

Namespace
Bindables
Assembly
Bindables.dll

A derived dictionary that automatically updates when its source bindable(s) change.

public class DerivedDictionary<TKey, TValue> : IBindableDictionary<TKey, TValue>, IBindable<Dictionary<TKey, TValue>>, IBindable, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable

Type Parameters

TKey

The type of keys in the dictionary.

TValue

The type of values in the dictionary.

Inheritance
DerivedDictionary<TKey, TValue>
Implements
IBindableDictionary<TKey, TValue>
IBindable<Dictionary<TKey, TValue>>
IReadOnlyDictionary<TKey, TValue>
IEnumerable<KeyValuePair<TKey, TValue>>
Inherited Members
Extension Methods

Remarks

This class creates a reactive dictionary derived from one or more bindable sources. The dictionary is lazy-evaluated and only subscribes to source changes when it has active listeners.

Properties

Count

public int Count { get; }

Property Value

int

this[TKey]

public TValue this[TKey key] { get; }

Parameters

key TKey

Property Value

TValue

Keys

public IEnumerable<TKey> Keys { get; }

Property Value

IEnumerable<TKey>

Value

Gets the current value of the bindable.

public Dictionary<TKey, TValue> Value { get; }

Property Value

Dictionary<TKey, TValue>

Values

public IEnumerable<TValue> Values { get; }

Property Value

IEnumerable<TValue>

Methods

ContainsKey(TKey)

public bool ContainsKey(TKey key)

Parameters

key TKey

Returns

bool

From<TSource>(IBindable<TSource>, Func<TSource, IBindableDictionary<TKey, TValue>>)

Creates a derived dictionary from a single bindable source.

public static DerivedDictionary<TKey, TValue> From<TSource>(IBindable<TSource> bindable, Func<TSource, IBindableDictionary<TKey, TValue>> func)

Parameters

bindable IBindable<TSource>

The source bindable to derive from.

func Func<TSource, IBindableDictionary<TKey, TValue>>

The function that transforms the source value into a bindable dictionary.

Returns

DerivedDictionary<TKey, TValue>

A new derived dictionary that updates when the source bindable changes.

Type Parameters

TSource

The type of the source bindable value.

From<TSource1, TSource2>(IBindable<TSource1>, IBindable<TSource2>, Func<TSource1, TSource2, IBindableDictionary<TKey, TValue>>)

Creates a derived dictionary from two bindable sources.

public static DerivedDictionary<TKey, TValue> From<TSource1, TSource2>(IBindable<TSource1> bindable1, IBindable<TSource2> bindable2, Func<TSource1, TSource2, IBindableDictionary<TKey, TValue>> func)

Parameters

bindable1 IBindable<TSource1>

The first source bindable to derive from.

bindable2 IBindable<TSource2>

The second source bindable to derive from.

func Func<TSource1, TSource2, IBindableDictionary<TKey, TValue>>

The function that transforms the source values into a bindable dictionary.

Returns

DerivedDictionary<TKey, TValue>

A new derived dictionary that updates when any source bindable changes.

Type Parameters

TSource1

The type of the first source bindable value.

TSource2

The type of the second source bindable value.

From<TSource1, TSource2, TSource3>(IBindable<TSource1>, IBindable<TSource2>, IBindable<TSource3>, Func<TSource1, TSource2, TSource3, IBindableDictionary<TKey, TValue>>)

Creates a derived dictionary from three bindable sources.

public static DerivedDictionary<TKey, TValue> From<TSource1, TSource2, TSource3>(IBindable<TSource1> bindable1, IBindable<TSource2> bindable2, IBindable<TSource3> bindable3, Func<TSource1, TSource2, TSource3, IBindableDictionary<TKey, TValue>> func)

Parameters

bindable1 IBindable<TSource1>

The first source bindable to derive from.

bindable2 IBindable<TSource2>

The second source bindable to derive from.

bindable3 IBindable<TSource3>

The third source bindable to derive from.

func Func<TSource1, TSource2, TSource3, IBindableDictionary<TKey, TValue>>

The function that transforms the source values into a bindable dictionary.

Returns

DerivedDictionary<TKey, TValue>

A new derived dictionary that updates when any source bindable changes.

Type Parameters

TSource1

The type of the first source bindable value.

TSource2

The type of the second source bindable value.

TSource3

The type of the third source bindable value.

From<TSource1, TSource2, TSource3, TSource4>(IBindable<TSource1>, IBindable<TSource2>, IBindable<TSource3>, IBindable<TSource4>, Func<TSource1, TSource2, TSource3, TSource4, IBindableDictionary<TKey, TValue>>)

Creates a derived dictionary from four bindable sources.

public static DerivedDictionary<TKey, TValue> From<TSource1, TSource2, TSource3, TSource4>(IBindable<TSource1> bindable1, IBindable<TSource2> bindable2, IBindable<TSource3> bindable3, IBindable<TSource4> bindable4, Func<TSource1, TSource2, TSource3, TSource4, IBindableDictionary<TKey, TValue>> func)

Parameters

bindable1 IBindable<TSource1>

The first source bindable to derive from.

bindable2 IBindable<TSource2>

The second source bindable to derive from.

bindable3 IBindable<TSource3>

The third source bindable to derive from.

bindable4 IBindable<TSource4>

The fourth source bindable to derive from.

func Func<TSource1, TSource2, TSource3, TSource4, IBindableDictionary<TKey, TValue>>

The function that transforms the source values into a bindable dictionary.

Returns

DerivedDictionary<TKey, TValue>

A new derived dictionary that updates when any source bindable changes.

Type Parameters

TSource1

The type of the first source bindable value.

TSource2

The type of the second source bindable value.

TSource3

The type of the third source bindable value.

TSource4

The type of the fourth source bindable value.

GetEnumerator()

public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<TKey, TValue>>

TryGetValue(TKey, out TValue)

public bool TryGetValue(TKey key, out TValue value)

Parameters

key TKey
value TValue

Returns

bool

Events

OnChange

Event triggered when the bindable value changes.

public event Action OnChange

Event Type

Action

OnChangeWithValue

Event triggered when the bindable value changes, providing the new value.

public event Action<Dictionary<TKey, TValue>> OnChangeWithValue

Event Type

Action<Dictionary<TKey, TValue>>

OnElementAdd

Occurs when an element is added to the dictionary.

public event Action<TKey, TValue> OnElementAdd

Event Type

Action<TKey, TValue>

OnElementChange

Occurs when an element's value is changed in the dictionary.

public event Action<TKey, TValue, TValue> OnElementChange

Event Type

Action<TKey, TValue, TValue>

OnElementRemove

Occurs when an element is removed from the dictionary.

public event Action<TKey, TValue> OnElementRemove

Event Type

Action<TKey, TValue>