-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ICommandHandler::ConnectorUpdateShort()
as a way to distinguish…
… using a short ID string vs. the full connector ID. Adds associated distinct class and a common base class for both ConnectorUpdate* derivatives.
- Loading branch information
Showing
5 changed files
with
81 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 4 additions & 26 deletions
30
TouchPortalSDK/Messages/Commands/ConnectorUpdateCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,13 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Text; | ||
using TouchPortalSDK.Interfaces; | ||
using TouchPortalSDK.Messages.Models; | ||
|
||
| ||
namespace TouchPortalSDK.Messages.Commands | ||
{ | ||
public class ConnectorUpdateCommand : ITouchPortalMessage | ||
public class ConnectorUpdateCommand : ConnectorUpdateCommandBase | ||
{ | ||
public string Type => "connectorUpdate"; | ||
|
||
public string ConnectorId { get; set; } | ||
|
||
public int Value { get; set; } | ||
public string ConnectorId { get { return Id; } set { Id = value; } } | ||
|
||
public ConnectorUpdateCommand(string pluginId, string connectorId, int value) | ||
public ConnectorUpdateCommand(string pluginId, string connectorId, int value) : base(pluginId, $"pc_{pluginId}_{connectorId}", value) | ||
{ | ||
if (string.IsNullOrWhiteSpace(pluginId)) | ||
throw new ArgumentNullException(nameof(pluginId)); | ||
|
||
if (string.IsNullOrWhiteSpace(connectorId)) | ||
throw new ArgumentNullException(nameof(connectorId)); | ||
|
||
if (value < 0 || value > 100) | ||
throw new ArgumentException("Value must be between 0 and 100", nameof(value)); | ||
|
||
ConnectorId = $"pc_{pluginId}_{connectorId}"; | ||
Value = value; | ||
} | ||
|
||
public Identifier GetIdentifier() | ||
=> new Identifier(Type, ConnectorId, default); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
TouchPortalSDK/Messages/Commands/ConnectorUpdateCommandBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Text; | ||
using TouchPortalSDK.Interfaces; | ||
using TouchPortalSDK.Messages.Models; | ||
|
||
namespace TouchPortalSDK.Messages.Commands | ||
{ | ||
public abstract class ConnectorUpdateCommandBase : ITouchPortalMessage | ||
{ | ||
public string Type => "connectorUpdate"; | ||
|
||
public string Id { get; set; } | ||
|
||
public int Value { get; set; } | ||
|
||
public ConnectorUpdateCommandBase(string pluginId, string id, int value) | ||
{ | ||
if (string.IsNullOrWhiteSpace(pluginId)) | ||
throw new ArgumentNullException(nameof(pluginId)); | ||
|
||
if (string.IsNullOrWhiteSpace(id)) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
if (value < 0 || value > 100) | ||
throw new ArgumentException("Value must be between 0 and 100", nameof(value)); | ||
|
||
Id = id; | ||
Value = value; | ||
} | ||
|
||
public Identifier GetIdentifier() | ||
=> new Identifier(Type, Id, default); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
TouchPortalSDK/Messages/Commands/ConnectorUpdateShortCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
| ||
namespace TouchPortalSDK.Messages.Commands | ||
{ | ||
public class ConnectorUpdateShortCommand : ConnectorUpdateCommandBase | ||
{ | ||
public string ShortId { get { return Id; } set { Id = value; } } | ||
|
||
public ConnectorUpdateShortCommand(string pluginId, string shortId, int value) : base(pluginId, shortId, value) { | ||
|
||
} | ||
} | ||
} |