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