添加项目文件。
This commit is contained in:
31
src/BRS.Common.Model/Factory/UIFactory.cs
Normal file
31
src/BRS.Common.Model/Factory/UIFactory.cs
Normal file
@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user