using Bro.Common.Helper;
|
using Bro.Common.Interface;
|
using System;
|
using System.Reflection;
|
|
namespace Bro.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, Helper.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, Helper.EnumHelper.DeviceAttributeType ctrlType)
|
{
|
var type = FactoryHelper.GetTypeByAtrributeTypeName(typeName, ctrlType);
|
|
return type != null;
|
}
|
}
|
}
|