using HMI.Core.Entity;
using HMI.Core.Util;
using System.Collections.Generic;
using System.IO;
namespace HMI.Core.Manager
{
///
/// TODO 优化数据源,需要支持sqlite和xml
///
public class ProductManager
{
///
/// 获取保存的产品
///
///
public static T GetProducts() where T : IList
{
string path = PathHelper.ProductDataFile;
if (!File.Exists(path)) return default(T);
T datas = XmlHelper.DeserializeFromXml(path);
return datas;
}
///
/// 获取保存的产品
///
///
public static T GetParametersByProductName(string productName) where T : IList
{
string path = Path.Combine(PathHelper.ProductParameterFolder, $"Parameter_{productName}.data");
if (!File.Exists(path)) return default(T);
T datas = XmlHelper.DeserializeFromXml(path);
return datas;
}
public static List GetProducts()
{
List datas = GetProducts>();
return datas ?? new List();
}
///
/// 根据产品名称获取产品参数
///
///
///
public static List GetParametersByProductName(string productName)
{
List datas = GetParametersByProductName>(productName);
return datas ?? new List();
}
}
}