refactor: make messenger constructors more consistent

Some constructors for messengers were taking Device rather than the specific type they needed.
This commit is contained in:
Andrew Welker
2025-03-26 08:55:07 -05:00
parent 6c710dd209
commit 8b3eda1d18
26 changed files with 59 additions and 112 deletions

View File

@@ -8,9 +8,9 @@ namespace PepperDash.Essentials.Room.MobileControl
{
private readonly IChannel channelDevice;
public IChannelMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
public IChannelMessenger(string key, string messagePath, IChannel device) : base(key, messagePath, device as IKeyName)
{
channelDevice = device as IChannel;
channelDevice = device;
}
protected override void RegisterActions()

View File

@@ -7,7 +7,7 @@ namespace PepperDash.Essentials.Room.MobileControl
public class IColorMessenger : MessengerBase
{
private readonly IColor colorDevice;
public IColorMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
public IColorMessenger(string key, string messagePath, IColor device) : base(key, messagePath, device as IKeyName)
{
colorDevice = device as IColor;
}

View File

@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
public class IDPadMessenger : MessengerBase
{
private readonly IDPad dpadDevice;
public IDPadMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
public IDPadMessenger(string key, string messagePath, IDPad device) : base(key, messagePath, device as IKeyName)
{
dpadDevice = device as IDPad;
dpadDevice = device;
}

View File

@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
public class IDvrMessenger : MessengerBase
{
private readonly IDvr dvrDevice;
public IDvrMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
public IDvrMessenger(string key, string messagePath, IDvr device) : base(key, messagePath, device as IKeyName)
{
dvrDevice = device as IDvr;
dvrDevice = device;
}
protected override void RegisterActions()

View File

@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
public class IHasPowerMessenger : MessengerBase
{
private readonly IHasPowerControl powerDevice;
public IHasPowerMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
public IHasPowerMessenger(string key, string messagePath, IHasPowerControl device) : base(key, messagePath, device as IKeyName)
{
powerDevice = device as IHasPowerControl;
powerDevice = device;
}
protected override void RegisterActions()

View File

@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
public class INumericKeypadMessenger : MessengerBase
{
private readonly INumericKeypad keypadDevice;
public INumericKeypadMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
public INumericKeypadMessenger(string key, string messagePath, INumericKeypad device) : base(key, messagePath, device as IKeyName)
{
keypadDevice = device as INumericKeypad;
keypadDevice = device;
}
protected override void RegisterActions()

View File

@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
public class ISetTopBoxControlsMessenger : MessengerBase
{
private readonly ISetTopBoxControls stbDevice;
public ISetTopBoxControlsMessenger(string key, string messagePath, IKeyName device) : base(key, messagePath, device)
public ISetTopBoxControlsMessenger(string key, string messagePath, ISetTopBoxControls device) : base(key, messagePath, device as IKeyName)
{
stbDevice = device as ISetTopBoxControls;
stbDevice = device;
}
protected override void RegisterActions()

View File

@@ -7,9 +7,9 @@ namespace PepperDash.Essentials.Room.MobileControl
public class ITransportMessenger : MessengerBase
{
private readonly ITransport transportDevice;
public ITransportMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
public ITransportMessenger(string key, string messagePath, ITransport device) : base(key, messagePath, device as IKeyName)
{
transportDevice = device as ITransport;
transportDevice = device;
}
protected override void RegisterActions()

View File

@@ -13,7 +13,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly IEssentialsRoomCombiner _roomCombiner;
public IEssentialsRoomCombinerMessenger(string key, string messagePath, IEssentialsRoomCombiner roomCombiner)
: base(key, messagePath, roomCombiner as Device)
: base(key, messagePath, roomCombiner as IKeyName)
{
_roomCombiner = roomCombiner;
}

View File

@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly IHasPowerControlWithFeedback _powerControl;
public IHasPowerControlWithFeedbackMessenger(string key, string messagePath, IHasPowerControlWithFeedback powerControl)
: base(key, messagePath, powerControl as Device)
: base(key, messagePath, powerControl as IKeyName)
{
_powerControl = powerControl;
}

View File

@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
public IHasScheduleAwareness ScheduleSource { get; private set; }
public IHasScheduleAwarenessMessenger(string key, IHasScheduleAwareness scheduleSource, string messagePath)
: base(key, messagePath, scheduleSource as Device)
: base(key, messagePath, scheduleSource as IKeyName)
{
ScheduleSource = scheduleSource ?? throw new ArgumentNullException("scheduleSource");
ScheduleSource.CodecSchedule.MeetingsListHasChanged += new EventHandler<EventArgs>(CodecSchedule_MeetingsListHasChanged);

View File

@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly IHumiditySensor device;
public IHumiditySensorMessenger(string key, IHumiditySensor device, string messagePath)
: base(key, messagePath, device as Device)
: base(key, messagePath, device as IKeyName)
{
this.device = device;
}

View File

@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
public class ILevelControlsMessenger : MessengerBase
{
private ILevelControls levelControlsDevice;
public ILevelControlsMessenger(string key, string messagePath, ILevelControls device) : base(key, messagePath, device as Device)
public ILevelControlsMessenger(string key, string messagePath, ILevelControls device) : base(key, messagePath, device as IKeyName)
{
levelControlsDevice = device;
}

View File

@@ -16,7 +16,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
public class IMatrixRoutingMessenger : MessengerBase
{
private readonly IMatrixRouting matrixDevice;
public IMatrixRoutingMessenger(string key, string messagePath, IMatrixRouting device) : base(key, messagePath, device as Device)
public IMatrixRoutingMessenger(string key, string messagePath, IMatrixRouting device) : base(key, messagePath, device as IKeyName)
{
matrixDevice = device;
}

View File

@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly IProjectorScreenLiftControl device;
public IProjectorScreenLiftControlMessenger(string key, string messagePath, IProjectorScreenLiftControl screenLiftDevice)
: base(key, messagePath, screenLiftDevice as Device)
: base(key, messagePath, screenLiftDevice as IKeyName)
{
device = screenLiftDevice;
}

View File

@@ -15,7 +15,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
public IRunRouteAction RoutingDevice { get; private set; }
public RunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath)
: base(key, messagePath, routingDevice as Device)
: base(key, messagePath, routingDevice as IKeyName)
{
RoutingDevice = routingDevice ?? throw new ArgumentNullException("routingDevice");

View File

@@ -9,10 +9,10 @@ namespace PepperDash.Essentials.AppServer.Messengers
public class ISelectableItemsMessenger<TKey> : MessengerBase
{
private static readonly JsonSerializer serializer = new JsonSerializer { Converters = { new StringEnumConverter() } };
private ISelectableItems<TKey> itemDevice;
private readonly ISelectableItems<TKey> itemDevice;
private readonly string _propName;
public ISelectableItemsMessenger(string key, string messagePath, ISelectableItems<TKey> device, string propName) : base(key, messagePath, device as Device)
public ISelectableItemsMessenger(string key, string messagePath, ISelectableItems<TKey> device, string propName) : base(key, messagePath, device as IKeyName)
{
itemDevice = device;
_propName = propName;

View File

@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly IShutdownPromptTimer _room;
public IShutdownPromptTimerMessenger(string key, string messagePath, IShutdownPromptTimer room)
: base(key, messagePath, room as Device)
: base(key, messagePath, room as IKeyName)
{
_room = room;
}

View File

@@ -11,7 +11,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly ISwitchedOutput device;
public ISwitchedOutputMessenger(string key, ISwitchedOutput device, string messagePath)
: base(key, messagePath, device as Device)
: base(key, messagePath, device as IKeyName)
{
this.device = device;
}

View File

@@ -9,7 +9,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly ITechPassword _room;
public ITechPasswordMessenger(string key, string messagePath, ITechPassword room)
: base(key, messagePath, room as Device)
: base(key, messagePath, room as IKeyName)
{
_room = room;
}

View File

@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly ITemperatureSensor device;
public ITemperatureSensorMessenger(string key, ITemperatureSensor device, string messagePath)
: base(key, messagePath, device as Device)
: base(key, messagePath, device as IKeyName)
{
this.device = device;
}

View File

@@ -11,7 +11,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
protected ILightingScenes Device { get; private set; }
public ILightingScenesMessenger(string key, ILightingScenes device, string messagePath)
: base(key, messagePath, device as Device)
: base(key, messagePath, device as IKeyName)
{
Device = device ?? throw new ArgumentNullException("device");
Device.LightingSceneChange += new EventHandler<LightingSceneChangeEventArgs>(LightingDevice_LightingSceneChange);

View File

@@ -14,7 +14,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
public RoomEventScheduleMessenger(string key, string messagePath, IRoomEventSchedule room)
: base(key, messagePath, room as Device)
: base(key, messagePath, room as IKeyName)
{
_room = room;
}

View File

@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private readonly IShadesOpenCloseStop device;
public IShadesOpenCloseStopMessenger(string key, IShadesOpenCloseStop shades, string messagePath)
: base(key, messagePath, shades as Device)
: base(key, messagePath, shades as IKeyName)
{
device = shades;
}

View File

@@ -9,12 +9,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
private readonly TwoWayDisplayBase _display;
public TwoWayDisplayBaseMessenger(string key, string messagePath) : base(key, messagePath)
{
}
public TwoWayDisplayBaseMessenger(string key, string messagePath, TwoWayDisplayBase display)
: this(key, messagePath)
: base(key, messagePath, display)
{
_display = display;
}