Class AbstractRGBDeviceProvider
Represents the abstract base implementation for a IRGBDeviceProvider.
Inheritance
Inherited Members
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider, IDisposableConstructors
| Edit this page View SourceAbstractRGBDeviceProvider(double)
Initializes a new instance of the AbstractRGBDeviceProvider class.
Declaration
protected AbstractRGBDeviceProvider(double defaultUpdateRateHardLimit = 0)Parameters
| Type | Name | Description | 
|---|---|---|
| double | defaultUpdateRateHardLimit | The update rate hard limit all update triggers for this device provider are initialized with. | 
Properties
| Edit this page View SourceDevices
Gets a collection of IRGBDevice loaded by this IRGBDeviceProvider.
Declaration
public virtual IReadOnlyList<IRGBDevice> Devices { get; }Property Value
| Type | Description | 
|---|---|
| IReadOnlyList<IRGBDevice> | 
InternalDevices
The list of devices managed by this device-provider.
Declaration
protected List<IRGBDevice> InternalDevices { get; }Property Value
| Type | Description | 
|---|---|
| List<IRGBDevice> | 
IsInitialized
Indicates if the used SDK is initialized and ready to use.
Declaration
public bool IsInitialized { get; protected set; }Property Value
| Type | Description | 
|---|---|
| bool | 
ThrowsExceptions
Indicates if exceptions in the device provider are thrown or silently ignored.
Declaration
public bool ThrowsExceptions { get; protected set; }Property Value
| Type | Description | 
|---|---|
| bool | 
Remarks
This should only be set to true for debugging/development purposes.
Production code should use the Exception-Event to handle exceptions.
UpdateTriggerMapping
Gets the dictionary containing the registered update triggers. Normally UpdateTriggers should be used to access them.
Declaration
protected Dictionary<int, IDeviceUpdateTrigger> UpdateTriggerMapping { get; }Property Value
| Type | Description | 
|---|---|
| Dictionary<int, IDeviceUpdateTrigger> | 
UpdateTriggers
Gets a collection IDeviceUpdateTrigger registered to this device provider.
Declaration
public IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers { get; }Property Value
| Type | Description | 
|---|---|
| IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> | 
Methods
| Edit this page View SourceAddDevice(IRGBDevice)
Adds the provided device to the list of managed devices.
Declaration
protected virtual bool AddDevice(IRGBDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| IRGBDevice | device | The device to add. | 
Returns
| Type | Description | 
|---|---|
| bool | 
 | 
CreateUpdateTrigger(int, double)
Creates a update trigger with the specified id and the specified update rate hard limit.
Declaration
protected virtual IDeviceUpdateTrigger CreateUpdateTrigger(int id, double updateRateHardLimit)Parameters
| Type | Name | Description | 
|---|---|---|
| int | id | The id of the update trigger. | 
| double | updateRateHardLimit | The update rate hard limit tobe set in the update trigger. | 
Returns
| Type | Description | 
|---|---|
| IDeviceUpdateTrigger | The newly created update trigger. | 
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()Dispose(bool)
Disposes the object and frees all resources.
Declaration
protected virtual void Dispose(bool disposing)Parameters
| Type | Name | Description | 
|---|---|---|
| bool | disposing | 
 | 
~AbstractRGBDeviceProvider()
Declaration
protected ~AbstractRGBDeviceProvider()GetLoadedDevices(RGBDeviceType)
Loads devices and returns a filtered list of them.
Declaration
protected virtual IEnumerable<IRGBDevice> GetLoadedDevices(RGBDeviceType loadFilter)Parameters
| Type | Name | Description | 
|---|---|---|
| RGBDeviceType | loadFilter | RGBDeviceType-flags to filter the device with. | 
Returns
| Type | Description | 
|---|---|
| IEnumerable<IRGBDevice> | The filtered collection of loaded devices. | 
Remarks
The underlying loading of the devices happens in LoadDevices().
GetUpdateTrigger(int, double?)
Gets the IDeviceUpdateTrigger mapped to the specified id or a new one if the id wasn't requested before.
Declaration
protected virtual IDeviceUpdateTrigger GetUpdateTrigger(int id = -1, double? updateRateHardLimit = null)Parameters
| Type | Name | Description | 
|---|---|---|
| int | id | The id of the update trigger. | 
| double? | updateRateHardLimit | The update rate hard limit to be set in the update trigger. | 
Returns
| Type | Description | 
|---|---|
| IDeviceUpdateTrigger | The update trigger mapped to the specified id. | 
Remarks
The creation of the update trigger happens in CreateUpdateTrigger(int, double).
Initialize(RGBDeviceType, bool)
Initializes the device provider and loads available devices.
Declaration
public bool Initialize(RGBDeviceType loadFilter = (RGBDeviceType)-1, bool throwExceptions = false)Parameters
| Type | Name | Description | 
|---|---|---|
| RGBDeviceType | loadFilter | RGBDeviceType-flags to filter the devices to load. | 
| bool | throwExceptions | Specifies if exceptions should be thrown or silently be ignored. | 
Returns
| Type | Description | 
|---|---|
| bool | 
 | 
InitializeSDK()
Initializes the underlying SDK.
Declaration
protected abstract void InitializeSDK()LoadDevices()
Loads all devices this device provider is capable of loading.
Declaration
protected abstract IEnumerable<IRGBDevice> LoadDevices()Returns
| Type | Description | 
|---|---|
| IEnumerable<IRGBDevice> | A collection of loaded devices. | 
Remarks
Filtering happens in GetLoadedDevices(RGBDeviceType).
OnDevicesChanged(DevicesChangedEventArgs)
Throws the DevicesChanged-event.
Declaration
protected virtual void OnDevicesChanged(DevicesChangedEventArgs args)Parameters
| Type | Name | Description | 
|---|---|---|
| DevicesChangedEventArgs | args | The parameters passed to the event. | 
OnException(ExceptionEventArgs)
Throws the Exception.event.
Declaration
protected virtual void OnException(ExceptionEventArgs args)Parameters
| Type | Name | Description | 
|---|---|---|
| ExceptionEventArgs | args | The parameters passed to the event. | 
RemoveDevice(IRGBDevice)
Removes the provided device from the list of managed devices.
Declaration
protected virtual bool RemoveDevice(IRGBDevice device)Parameters
| Type | Name | Description | 
|---|---|---|
| IRGBDevice | device | The device to remove. | 
Returns
| Type | Description | 
|---|---|
| bool | 
 | 
Reset()
Resets the device provider and disposes all devices and update triggers.
Declaration
protected virtual void Reset()Throw(Exception, bool)
Triggers the Exception-event and throws the specified exception if ThrowsExceptions is true and it is not overriden in the event.
Declaration
public virtual void Throw(Exception ex, bool isCritical = false)Parameters
| Type | Name | Description | 
|---|---|---|
| Exception | ex | The exception to throw. | 
| bool | isCritical | Indicates if the exception is critical for device provider to work correctly. | 
Events
| Edit this page View SourceDevicesChanged
Occures when the devices provided by this device provider changed.
Declaration
public event EventHandler<DevicesChangedEventArgs>? DevicesChangedEvent Type
| Type | Description | 
|---|---|
| EventHandler<DevicesChangedEventArgs> | 
Exception
Occurs when an exception is thrown in the device provider.
Declaration
public event EventHandler<ExceptionEventArgs>? ExceptionEvent Type
| Type | Description | 
|---|---|
| EventHandler<ExceptionEventArgs> |