Files
ShaftControlCodes/src/BRS.Common.Model/Factory/UIFactory.cs
2023-02-23 14:52:43 +08:00

32 lines
944 B
C#

using BRS.Common.Interface;
using BRS.Common.Model.Helper;
using System;
using System.Reflection;
namespace BRS.Common.Factory
{
public class UIFactory
{
public static IRunCtrl GetRunCtrl(IDevice device)
{
var attr = device.GetType().GetCustomAttribute<DeviceAttribute>();
if (attr == null)
return null;
var type = FactoryHelper.GetTypeByAtrributeTypeName(attr.TypeCode, EnumHelper.DeviceAttributeType.RunCtrl);
if (type == null)
return null;
IRunCtrl runCtrl = Activator.CreateInstance(type, new object[] { device }) as IRunCtrl;
return runCtrl;
}
public static bool IsDeviceCtrlExisted(string typeName, EnumHelper.DeviceAttributeType ctrlType)
{
var type = FactoryHelper.GetTypeByAtrributeTypeName(typeName, ctrlType);
return type != null;
}
}
}