using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Reflection;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class EtaCalculationFactory
|
{
|
private const string DllName_Custom = "IStation.EtaCalculation4Custom";
|
private const string NameSpace_Custom = "IStation.EtaCalculation";
|
|
//获取DLL名称
|
private static string DllName
|
{
|
get
|
{
|
var dllName = string.Empty;
|
var selector = Settings.Eta.Analy.Method;
|
if (selector == 1)
|
{
|
dllName = DllName_Custom;
|
}
|
return dllName;
|
}
|
}
|
|
private static string NameSpace
|
{
|
get
|
{
|
var ns = string.Empty;
|
var selector = Settings.Eta.Analy.Method;
|
if (selector == 1)
|
{
|
ns = NameSpace_Custom;
|
}
|
return ns;
|
}
|
}
|
|
/// <summary>
|
/// 创建
|
/// </summary>
|
public static I CreateT<I>()
|
{
|
var dllName = DllName;
|
if (string.IsNullOrEmpty(dllName))
|
{
|
LogHelper.Error($"EtaCalculationFactory工厂创建接口对象失败,请检查相关配置参数!");
|
return default;
|
}
|
var ns = NameSpace;
|
if (string.IsNullOrEmpty(ns))
|
{
|
LogHelper.Error($"EtaCalculationFactory工厂创建接口对象失败,请检查相关配置参数!");
|
return default;
|
}
|
|
var type = typeof(I);
|
var className = string.Format("{0}.{1}", ns, type.Name.Remove(0, 1));
|
var obj = Assembly.Load(dllName).CreateInstance(className);
|
return (I)obj;
|
}
|
/// <summary>
|
/// 创建
|
/// </summary>
|
public static IStation.IEtaCalculation.IAnalyCalculator Create(long CorpID)
|
{
|
if (CorpID == 4)
|
return new IStation.EtaCalculation.AnalyCalculator4SHYS();
|
else if (CorpID == 5)
|
return new IStation.EtaCalculation.AnalyCalculatorSMI();
|
else
|
return null;
|
}
|
|
}
|
}
|