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
TKeyThe type of keys in the dictionary.
TValueThe type of values in the dictionary.
- Inheritance
-
DerivedDictionary<TKey, TValue>
- Implements
-
IBindableDictionary<TKey, TValue>IBindable<Dictionary<TKey, TValue>>IReadOnlyDictionary<TKey, TValue>IReadOnlyCollection<KeyValuePair<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
this[TKey]
public TValue this[TKey key] { get; }
Parameters
keyTKey
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
keyTKey
Returns
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
bindableIBindable<TSource>The source bindable to derive from.
funcFunc<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
TSourceThe 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
bindable1IBindable<TSource1>The first source bindable to derive from.
bindable2IBindable<TSource2>The second source bindable to derive from.
funcFunc<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
TSource1The type of the first source bindable value.
TSource2The 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
bindable1IBindable<TSource1>The first source bindable to derive from.
bindable2IBindable<TSource2>The second source bindable to derive from.
bindable3IBindable<TSource3>The third source bindable to derive from.
funcFunc<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
TSource1The type of the first source bindable value.
TSource2The type of the second source bindable value.
TSource3The 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
bindable1IBindable<TSource1>The first source bindable to derive from.
bindable2IBindable<TSource2>The second source bindable to derive from.
bindable3IBindable<TSource3>The third source bindable to derive from.
bindable4IBindable<TSource4>The fourth source bindable to derive from.
funcFunc<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
TSource1The type of the first source bindable value.
TSource2The type of the second source bindable value.
TSource3The type of the third source bindable value.
TSource4The 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
keyTKeyvalueTValue
Returns
Events
OnChange
Event triggered when the bindable value changes.
public event Action OnChange
Event Type
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>