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 { /// /// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class /// public abstract class EssentialsDevice : Device { protected EssentialsDevice(string key) : base(key) { } protected EssentialsDevice(string key, string name) : base(key, name) { } } /// /// Devices the basic needs for a Device Factory /// public abstract class EssentialsDeviceFactory : IDeviceFactory where T:EssentialsDevice { #region IDeviceFactory Members /// /// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device /// public List TypeNames { get; protected set; } /// /// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list /// public void LoadTypeFactories() { foreach (var typeName in TypeNames) { DeviceFactory.AddFactoryForType(typeName, BuildDevice); } } /// /// The method that will build the device /// /// The device config /// An instance of the device public abstract EssentialsDevice BuildDevice(DeviceConfig dc); #endregion } /// /// Devices the basic needs for a Device Factory /// public abstract class EssentialsPluginDeviceFactory : EssentialsDeviceFactory, IPluginDeviceFactory where T : EssentialsDevice { /// /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") /// public string MinimumEssentialsFrameworkVersion { get; protected set; } } }