mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-15 05:27:16 +00:00
chore: move all files to file-scoped namespace
This commit is contained in:
parent
aaa5b0532b
commit
3ece4f0b7b
522 changed files with 39628 additions and 45678 deletions
|
|
@ -12,95 +12,67 @@ using PepperDash.Essentials.Core.Config;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PepperDash.Essentials.Core.Devices
|
||||
namespace PepperDash.Essentials.Core.Devices;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class ReconfigurableDevice : EssentialsDevice, IReconfigurableDevice
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class ReconfigurableDevice : EssentialsDevice, IReconfigurableDevice
|
||||
public event EventHandler<EventArgs> ConfigChanged;
|
||||
|
||||
public DeviceConfig Config { get; private set; }
|
||||
|
||||
protected ReconfigurableDevice(DeviceConfig config)
|
||||
: base(config.Key)
|
||||
{
|
||||
/// <summary>
|
||||
/// Event fired when the configuration changes
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> ConfigChanged;
|
||||
SetNameHelper(config);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current DeviceConfig
|
||||
/// </summary>
|
||||
public DeviceConfig Config { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="config">config of the device</param>
|
||||
protected ReconfigurableDevice(DeviceConfig config)
|
||||
: base(config.Key)
|
||||
{
|
||||
SetNameHelper(config);
|
||||
|
||||
Config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Config, calls CustomSetConfig and fires the ConfigChanged event
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <summary>
|
||||
/// SetConfig method
|
||||
/// </summary>
|
||||
public void SetConfig(DeviceConfig config)
|
||||
{
|
||||
Config = config;
|
||||
|
||||
SetNameHelper(config);
|
||||
|
||||
CustomSetConfig(config);
|
||||
|
||||
var handler = ConfigChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
void SetNameHelper(DeviceConfig config)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(config.Name))
|
||||
Name = config.Name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc)
|
||||
/// </summary>
|
||||
/// <param name="config">config of the device</param>
|
||||
protected virtual void CustomSetConfig(DeviceConfig config)
|
||||
{
|
||||
ConfigWriter.UpdateDeviceConfig(config);
|
||||
}
|
||||
Config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A ReconfigurableDevice that is also bridgeable
|
||||
/// Sets the Config, calls CustomSetConfig and fires the ConfigChanged event
|
||||
/// </summary>
|
||||
public abstract class ReconfigurableBridgableDevice : ReconfigurableDevice, IBridgeAdvanced
|
||||
/// <param name="config"></param>
|
||||
public void SetConfig(DeviceConfig config)
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="config">config of the device</param>
|
||||
protected ReconfigurableBridgableDevice(DeviceConfig config) : base(config)
|
||||
{
|
||||
}
|
||||
Config = config;
|
||||
|
||||
/// <summary>
|
||||
/// LinkToApi method
|
||||
/// </summary>
|
||||
/// <param name="trilist">trilist to link</param>
|
||||
/// <param name="joinStart">the join to start at</param>
|
||||
/// <param name="joinMapKey">key to the join map</param>
|
||||
/// <param name="bridge">the bridge to use</param>
|
||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
SetNameHelper(config);
|
||||
|
||||
CustomSetConfig(config);
|
||||
|
||||
var handler = ConfigChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
void SetNameHelper(DeviceConfig config)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(config.Name))
|
||||
Name = config.Name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc)
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
protected virtual void CustomSetConfig(DeviceConfig config)
|
||||
{
|
||||
ConfigWriter.UpdateDeviceConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ReconfigurableBridgableDevice : ReconfigurableDevice, IBridgeAdvanced
|
||||
{
|
||||
protected ReconfigurableBridgableDevice(DeviceConfig config) : base(config)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue