mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
fix: add constructor that takes IHasInputs<T>
In order to satisfy the requirements for the `MessengerBase` class, the `ISelectableItemsMessenger` class needs to take an `IHasInputs<T>`, as that is the device that implements `IKeyName`. We may want to consider adding a `IHasInputsMessenger` specifically for those devices that implement that interface vs the `ISelectableItemsMessenger`.
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
@@ -10,17 +8,37 @@ using System.Collections.Generic;
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
public class ISelectableItemsMessenger<TKey> : MessengerBase
|
||||
{
|
||||
private static readonly JsonSerializer serializer = new JsonSerializer { Converters = { new StringEnumConverter() } };
|
||||
{
|
||||
private readonly ISelectableItems<TKey> itemDevice;
|
||||
|
||||
private readonly string _propName;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a messenger for a device that implements ISelectableItems<typeparamref name="TKey"/>
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="messagePath"></param>
|
||||
/// <param name="device"></param>
|
||||
/// <param name="propName"></param>
|
||||
public ISelectableItemsMessenger(string key, string messagePath, ISelectableItems<TKey> device, string propName) : base(key, messagePath, device as IKeyName)
|
||||
{
|
||||
itemDevice = device;
|
||||
_propName = propName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a messenger for a device that implements IHasInputs<typeparamref name="TKey"/>
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="messagePath"></param>
|
||||
/// <param name="device"></param>
|
||||
/// <param name="propName"></param>
|
||||
public ISelectableItemsMessenger(string key, string messagePath, IHasInputs<TKey> device, string propName) : base(key, messagePath, device)
|
||||
{
|
||||
itemDevice = device.Inputs;
|
||||
_propName = propName;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
{
|
||||
base.RegisterActions();
|
||||
|
||||
@@ -766,7 +766,7 @@ namespace PepperDash.Essentials
|
||||
var messenger = new ISelectableItemsMessenger<string>(
|
||||
$"{device.Key}-inputs-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
stringInputs.Inputs,
|
||||
stringInputs,
|
||||
"inputs"
|
||||
);
|
||||
|
||||
@@ -782,7 +782,7 @@ namespace PepperDash.Essentials
|
||||
var messenger = new ISelectableItemsMessenger<byte>(
|
||||
$"{device.Key}-inputs-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
byteInputs.Inputs,
|
||||
byteInputs,
|
||||
"inputs"
|
||||
);
|
||||
|
||||
@@ -798,7 +798,7 @@ namespace PepperDash.Essentials
|
||||
var messenger = new ISelectableItemsMessenger<int>(
|
||||
$"{device.Key}-inputs-{Key}",
|
||||
$"/device/{device.Key}",
|
||||
intInputs.Inputs,
|
||||
intInputs,
|
||||
"inputs"
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user