10 where TInstance : class
63 ArgumentNullException.ThrowIfNull(instance);
70 throw new InvalidOperationException($
"{nameof(ReferenceCounter<TInstance>)} already initialized!");
96 return new InvalidOperationException($
"{nameof(ReferenceCounter<TInstance>)} not initialized!");
Class used for counting references with ReferenceCountingContainer<TWrapped, TReference>.
void DangerousDropReference()
Prevents the aquired reference from being dropped when Dispose is called.
readonly object initDisposeLock
The lock object for Initialize(TInstance, Action) and Dispose.
void Initialize(TInstance instance, Action referenceCleanupAction)
Initialize the ReferenceCounter<TInstance>.
TInstance Instance
The referenced TInstance .
bool initialized
If the ReferenceCounter<TInstance> was initialized.
ReferenceCounter()
Initializes a new instance of the ReferenceCounter<TInstance> class.
InvalidOperationException UninitializedOrDisposedException()
Throw the appropriate InvalidOperationException when the ReferenceCounter<TInstance> is uninitialized...
Action? referenceCleanupAction
The Action to take when Dispose is called.
TInstance? actualInstance
Backing field for Instance.