OperationalStatePropertyClean Method

Helper method to ensure that Value properties are of the expected type after de=serialisation by DeserializeTValue(String, JsonSerializerOptions)

Definition

Namespace: ASCOM.Common.DeviceInterfaces
Assembly: ASCOM.Common (in ASCOM.Common.dll) Version: 3.0.0-rc.1+86c25ce733aebb4d8b1b8a62e84770ea5e972bea
C#
public static List<StateValue> Clean(
	List<StateValue> deviceState,
	DeviceTypes deviceType,
	ILogger logger = null
)

Parameters

deviceState  ListStateValue
List of device state values returned by the device
deviceType  DeviceTypes
The device type (Camera,Telescope etc.)
logger  ILogger  (Optional)
Optional ILogger instance to receive operational log messages (defaults to null)

Return Value

ListStateValue
A cleaned list of device state values

Remarks

When de-serialising StateValue objects in a DeviceState response, System.Text.JSON returns the Value property as type JsonElement rather than the type sent by the device, which may have been int, double, string, DateTime etc. This method parses a list of StateValue objects and converts all JsonElement types in Value to the expected data type.

Exceptions

InvalidValueExceptionIf the supplied device type is not supported.

Version Information

.NET Standard

Supported in: 2.0

See Also