I\'m trying to nut out the details for a true WeakKeyedDictionary<,>
for C#... but I\'m running into difficulties.
I realise this is a non-trivial
Have a look at the ConditionalWeakTable<TKey, TValue> Class.
Enables compilers to dynamically attach object fields to managed objects.
It's essentially a dictionary where both the key and the value are a WeakReference, and the value is kept alive as long as the key is alive.
Note! This class does not use GetHashCode
and Equals
to do equality comparisons, it uses ReferenceEquals
.