Table of Contents

Class DeviceRegistryExtensions

Namespace
Acuit.Pinpoint.IO
Assembly
Acuit.Pinpoint.IO.Abstractions.dll

Extension members for IDeviceRegistry.

public static class DeviceRegistryExtensions
Inheritance
DeviceRegistryExtensions
Inherited Members

Methods

GetDeviceList<TDevice>(IDeviceRegistry)

Gets the list of registered devices of a particular device type.

public static IReadOnlyList<IRegisteredDevice<TDevice>> GetDeviceList<TDevice>(this IDeviceRegistry deviceRegistry) where TDevice : class

Parameters

deviceRegistry IDeviceRegistry

Returns

IReadOnlyList<IRegisteredDevice<TDevice>>

The list of devices.

Type Parameters

TDevice

The device type.

Remarks

Any configuration changes while the application is running that cause the device list for type TDevice to be regenerated will cause all active devices of that type to be disposed (if they implement IDisposable and recreated from the new configuration. While configuration changes typically only happen during application startup, clients should nonetheless hold on to and use the returned references for only as long as is needed.

GetDeviceService<TService>(IDeviceRegistry, Type)

Attempts to get a service registered for a device type.

public static TService? GetDeviceService<TService>(this IDeviceRegistry deviceRegistry, Type deviceType) where TService : notnull

Parameters

deviceRegistry IDeviceRegistry
deviceType Type

The device type.

Returns

TService

The first service of type TService in the list of services specified for the registered device type deviceType, or the default value for TService if the device type deviceType is not registered, or there is no service of type TService specified for the device type.

Type Parameters

TService

The service type.

Exceptions

ArgumentNullException

deviceType is null.

GetDevice<TDevice>(IDeviceRegistry, string?)

Gets a registered device of a particular device type.

public static TDevice? GetDevice<TDevice>(this IDeviceRegistry deviceRegistry, string? name = null) where TDevice : class

Parameters

deviceRegistry IDeviceRegistry
name string

An optional device name.

Returns

TDevice

The device, or null if not found. See the remarks for more details.

Type Parameters

TDevice

The device type.

Remarks

  1. If device type TDevice has never been registered or currently has no configured devices, null will be returned.
  2. Otherwise, if name is null or empty, then the first registered device of type TDevice will be returned.
  3. Otherwise, the first registered device of type TDevice with a name that matches name (case-sensitive) will be returned, or null if a match is not found.

Any configuration changes while the application is running that cause the device list for type TDevice to be regenerated will cause all active devices of that type to be disposed (if they implement IDisposable and recreated from the new configuration. While configuration changes typically only happen during application startup, clients should nonetheless hold on to and use the returned reference for only as long as is needed.