mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-12 12:06:58 +00:00
Attempt at modifying device factory mechanism
This commit is contained in:
parent
ca27e01f94
commit
a403a8b81f
7 changed files with 120 additions and 12 deletions
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class
|
||||
/// </summary>
|
||||
public abstract class EssentialsDevice : Device
|
||||
{
|
||||
public EssentialsDevice(string key)
|
||||
: base(key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract class Factory : IDeviceFactory
|
||||
{
|
||||
#region IDeviceFactory Members
|
||||
|
||||
public List<string> TypeNames { get; protected set; }
|
||||
|
||||
public virtual void LoadTypeFactories()
|
||||
{
|
||||
foreach (var typeName in TypeNames)
|
||||
{
|
||||
DeviceFactory.AddFactoryForType(typeName, BuildDevice);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public abstract IKeyed BuildDevice(DeviceConfig dc);
|
||||
|
||||
public Factory()
|
||||
{
|
||||
TypeNames = new List<string>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Core.Devices
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public abstract class ReconfigurableDevice : Device
|
||||
public abstract class ReconfigurableDevice : EssentialsDevice
|
||||
{
|
||||
public event EventHandler<EventArgs> ConfigChanged;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue