领胜LDS 键盘AOI检测项目
wells.liu
2020-07-11 a7d80280f67e3a498b7aa6622bbf00c15407da05
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
        }
    }
}