[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Enables compilers to dynamically attach object fields to objects.
<ComVisibleAttribute(False)> _ Public NotInheritable Class ConditionalWeakTable(Of TKey As Class, TValue As Class)
Dim instance As ConditionalWeakTable(Of TKey, TValue)
[ComVisibleAttribute(false)] public sealed class ConditionalWeakTable<TKey, TValue> where TKey : class where TValue : class
[ComVisibleAttribute(false)] generic<typename TKey, typename TValue> where TKey : ref class where TValue : ref class public ref class ConditionalWeakTable sealed
[<SealedAttribute>] [<ComVisibleAttribute(false)>] type ConditionalWeakTable<'TKey, 'TValue when 'TKey : not struct when 'TValue : not struct> = class end
The generic key type.
The generic value type.
Language compilers can expose the ability to attach arbitrary properties to managed objects at run time. The ConditionalWeakTable<(Of <(TKey, TValue>)>) class provides this support as a dictionary whose keys are the instanced objects and whose values are the properties.
ConditionalWeakTable<(Of <(TKey, TValue>)>) has the following characteristics:
It is referred to as a table, rather than a dictionary, because unlike a regular dictionary, ConditionalWeakTable<(Of <(TKey, TValue>)>) does not persist keys. In addition, ConditionalWeakTable<(Of <(TKey, TValue>)>) does not implement the IDictionary<(Of <(TKey, TValue>)>) interface, and, therefore, does not implement all the methods that a dictionary should have.
Inserting a key and value into the table will not cause the key to persist even if the key can be reached directly from normal program code. As soon as the key is detached from a managed object, ConditionalWeakTable<(Of <(TKey, TValue>)>) automatically removes the key/value entry.
It mirrors the form and functionality of the IDictionary<(Of <(TKey, TValue>)>) interface. However, it is also thread safe and requires no additional locking by callers.
It is not intended to be a general-purpose collection, and does not implement IDictionary<(Of <(TKey, TValue>)>) or expose the full IDictionary<(Of <(TKey, TValue>)>) public surface area.
Equality is defined to be Object..::.ReferenceEquals.
It does not invoke Object..::.GetHashCode overrides.
ConditionalWeakTable<(Of <(TKey, TValue>)>) operations detect internal data corruption. If the table is corrupt, table operations raise an InvalidOperationException exception. This exception is not expected to occur, and there is no need to catch it in application code.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003