Class WeakReferenceEventListener<TInstance, TSource>
Defines a model for providing a weak referenced event listener.
public sealed class WeakReferenceEventListener<TInstance, TSource> where TInstance : class
Type Parameters
TInstanceThe instance type for the listener.
TSourceThe source type.
- Inheritance
-
WeakReferenceEventListener<TInstance, TSource>
- Inherited Members
- Extension Methods
Constructors
WeakReferenceEventListener(TInstance)
Initializes a new instance of the WeakReferenceEventListener<TInstance, TSource> class.
public WeakReferenceEventListener(TInstance instance)
Parameters
instanceTInstanceThe instance.
Exceptions
- ArgumentNullException
Thrown if the
instanceis null.
Properties
OnDetachAction
Gets or sets the action to be fired when the listener is detached.
public Action<TInstance, WeakReferenceEventListener<TInstance, TSource>>? OnDetachAction { get; set; }
Property Value
- Action<TInstance, WeakReferenceEventListener<TInstance, TSource>>
OnEventAction
Gets or sets the action to be fired when the event is triggered.
public Action<TInstance, TSource>? OnEventAction { get; set; }
Property Value
- Action<TInstance, TSource>
Methods
Detach()
Called when detaching the event listener.
public void Detach()
Exceptions
- Exception
Potentially thrown by the OnDetachAction delegate callback.
OnEvent(TSource)
Called when the event is fired.
public void OnEvent(TSource source)
Parameters
sourceTSourceThe source of the event.
Exceptions
- Exception
Potentially thrown by the OnEventAction delegate callback.