27 lines
802 B
C#
27 lines
802 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using XKRS.Common.Interface;
|
|
using XKRS.Common.Model.Helper;
|
|
|
|
namespace XKRS.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.GetTypeByAttributeTypeName(attr.TypeCode, EnumHelper.DeviceAttributeType.RunCtrl);
|
|
if (type == null)
|
|
return null;
|
|
IRunCtrl runCtrl = Activator.CreateInstance(type, new object[] { device }) as IRunCtrl;
|
|
return runCtrl;
|
|
}
|
|
}
|
|
}
|