using System;
using System.Collections.Generic;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core
{
///
/// Represents a factory for creating processor extension devices.
///
/// The type of the processor extension device.
[Obsolete("will be removed in a future version")]
public abstract class ProcessorExtensionDeviceFactory : IProcessorExtensionDeviceFactory where T : EssentialsDevice
{
#region IProcessorExtensionDeviceFactory Members
///
/// Gets or sets the TypeNames
///
public List TypeNames { get; protected set; }
///
/// LoadFactories method
///
public void LoadFactories()
{
foreach (var typeName in TypeNames)
{
string description = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) is DescriptionAttribute[] descriptionAttribute && descriptionAttribute.Length > 0
? descriptionAttribute[0].Description
: "No description available";
ProcessorExtensionDeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice);
}
}
///
/// The method that will build the device
///
/// The device config
/// An instance of the device
public abstract EssentialsDevice BuildDevice(DeviceConfig dc);
#endregion
}
}