Interface IDeviceEventArgs<TDevice>
Defines the contract for device-related event arguments in a generic context. This interface allows for type-safe access to device information in event handling scenarios, supporting device types that implement the IDevice interface. It enables specific device type information to be preserved and accessed in event handlers.
public interface IDeviceEventArgs<out TDevice> where TDevice : IDevice
Type Parameters
TDevice
The specific type of IDevice this event argument represents. This type parameter is covariant, allowing for more specific device types to be used where a more general device type is expected.
Remarks
While this interface does not inherit from System.EventArgs, it retains the "Args" suffix in its name. This naming convention is deliberately chosen to maintain consistency with standard event argument naming patterns in C#, particularly for improved readability when used in delegate and event handler signatures. The familiar "Args" suffix clearly indicates the interface's role in event-related contexts, despite not directly extending System.EventArgs.
Properties
Device
Gets the specific type of IDevice that originated the event. This property will always be populated, regardless of whether this is an arrival event or a removal event. If the device was removed, not all members will be available on the object. An exception will be thrown if you try to use the device in a way that requires it to be present.
TDevice Device { get; }
Property Value
- TDevice
An instance of
TDevice
that triggered this event.
Remarks
This property provides access to the specific TDevice
instance associated with the current event.