Skip to content

Class PrecompiledEventDescriptor<TTarget, THandler>

Definition

Namespace: StardewUI.Framework.Descriptors
Assembly: StardewUI.dll

Statically-typed implementation of an IEventDescriptor with predefined attributes.

public class PrecompiledEventDescriptor<TTarget, THandler> : 
    StardewUI.Framework.Descriptors.IEventDescriptor, 
    StardewUI.Framework.Descriptors.IMemberDescriptor

Type Parameters

TTarget
The event's declaring type.

THandler
The delegate type of event handlers.

Inheritance
Object ⇦ PrecompiledEventDescriptor<TTarget, THandler>

Implements
IEventDescriptor, IMemberDescriptor

Members

Constructors

Name Description
PrecompiledEventDescriptor<TTarget, THandler>(string, Action<TTarget, THandler>, Action<TTarget, THandler>, Type) Statically-typed implementation of an IEventDescriptor with predefined attributes.

Properties

Name Description
ArgsTypeDescriptor Descriptor for the type of event object (arguments), generally a subtype of EventArgs.
DeclaringType The type on which the member is declared.
DelegateParameterCount Number of parameters that the Invoke method of the DelegateType accepts.
DelegateType The type (subtype of Delegate) that can be added/removed from the event handlers.
Name The member name.

Methods

Name Description
Add(Object, Delegate) Adds an event handler.
Remove(Object, Delegate) Removes an event handler.

Details

Constructors

PrecompiledEventDescriptor<TTarget, THandler>(string, Action<TTarget, THandler>, Action<TTarget, THandler>, Type)

Statically-typed implementation of an IEventDescriptor with predefined attributes.

public PrecompiledEventDescriptor<TTarget, THandler>(string name, Action<TTarget, THandler> add, Action<TTarget, THandler> remove, System.Type argsType);
Parameters

name   string
The event name.

add   Action<TTarget, THandler>
Function to add a new event handler to an instance of the target type.

remove   Action<TTarget, THandler>
Function to remove an existing event handler from an instance of the target type.

argsType   Type
Type of the argument parameter in the THandler delegate.


Properties

ArgsTypeDescriptor

Descriptor for the type of event object (arguments), generally a subtype of EventArgs.

public StardewUI.Framework.Descriptors.IObjectDescriptor ArgsTypeDescriptor { get; }
Property Value

IObjectDescriptor


DeclaringType

The type on which the member is declared.

public System.Type DeclaringType { get; }
Property Value

Type


DelegateParameterCount

Number of parameters that the Invoke method of the DelegateType accepts.

public int DelegateParameterCount { get; }
Property Value

Int32

Remarks

For precompiled descriptors, this is assumed to always be exactly 2 (sender and args).


DelegateType

The type (subtype of Delegate) that can be added/removed from the event handlers.

public System.Type DelegateType { get; }
Property Value

Type


Name

The member name.

public string Name { get; }
Property Value

string


Methods

Add(Object, Delegate)

Adds an event handler.

public void Add(System.Object target, System.Delegate handler);
Parameters

target   Object
The instance of the DeclaringType on which to subscribe to events.

handler   Delegate
The handler to run when the event is raised; must be assignable to the DelegateType.


Remove(Object, Delegate)

Removes an event handler.

public void Remove(System.Object target, System.Delegate handler);
Parameters

target   Object
The instance of the DeclaringType on which to unsubscribe from events.

handler   Delegate
The handler that was previously registered, i.e. via Add(Object, Delegate).