mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-04 23:35:02 +00:00
Attempt at modifying device factory mechanism
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user