Table of Contents

Class AppEntityInfoToModel

Namespace
RustPlusApi.Extensions
Assembly
RustPlusApi.dll

Mapping extensions from protobuf entity messages to entity model types.

public static class AppEntityInfoToModel
Inheritance
AppEntityInfoToModel
Inherited Members

Methods

ToAlarmInfo(AppEntityInfo)

Maps an RustPlusContracts.AppEntityInfo of type Alarm to a SmartDeviceInfo.

public static SmartDeviceInfo ToAlarmInfo(this AppEntityInfo entity)

Parameters

entity AppEntityInfo

The protobuf entity info.

Returns

SmartDeviceInfo

Exceptions

InvalidOperationException

Thrown when the entity type is not Alarm.

ToSmartDeviceInfo(AppEntityInfo)

Maps an RustPlusContracts.AppEntityInfo of a binary-state smart device (a smart switch or a smart alarm) to a SmartDeviceInfo. The server replies with the entity's actual type and switch/alarm payloads are physically identical, so both types are accepted.

public static SmartDeviceInfo ToSmartDeviceInfo(this AppEntityInfo entity)

Parameters

entity AppEntityInfo

The protobuf entity info.

Returns

SmartDeviceInfo

Exceptions

InvalidOperationException

Thrown when the entity type is neither Switch nor Alarm.

ToSmartSwitchInfo(AppEntityInfo)

Maps an RustPlusContracts.AppEntityInfo of type Switch to a SmartDeviceInfo.

public static SmartDeviceInfo ToSmartSwitchInfo(this AppEntityInfo entity)

Parameters

entity AppEntityInfo

The protobuf entity info.

Returns

SmartDeviceInfo

Exceptions

InvalidOperationException

Thrown when the entity type is not Switch.

ToStorageMonitorInfo(AppEntityInfo)

Maps an RustPlusContracts.AppEntityInfo of type StorageMonitor to a StorageMonitorInfo.

public static StorageMonitorInfo ToStorageMonitorInfo(this AppEntityInfo entity)

Parameters

entity AppEntityInfo

The protobuf entity info.

Returns

StorageMonitorInfo

Exceptions

InvalidOperationException

Thrown when the entity type is not StorageMonitor.

ToStorageMonitorItemInfo(Item)

Maps a single protobuf storage item to a StorageMonitorItemInfo.

public static StorageMonitorItemInfo ToStorageMonitorItemInfo(this AppEntityPayload.Item item)

Parameters

item AppEntityPayload.Item

The protobuf storage item.

Returns

StorageMonitorItemInfo

ToStorageMonitorItemsInfo(IEnumerable<Item>)

Maps a sequence of protobuf storage items to StorageMonitorItemInfo instances.

public static IEnumerable<StorageMonitorItemInfo> ToStorageMonitorItemsInfo(this IEnumerable<AppEntityPayload.Item> items)

Parameters

items IEnumerable<AppEntityPayload.Item>

The protobuf storage items to map.

Returns

IEnumerable<StorageMonitorItemInfo>