using HMI.Core.Util;
|
using HMI.ParameterManage.Entity;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.IO;
|
|
namespace HMI.ParameterManage.Util
|
{
|
/// <summary>
|
/// TODO 优化数据源,需要支持sqlite和xml
|
/// </summary>
|
public class TestItemManager
|
{
|
/// <summary>
|
/// 根据产品获取测试项
|
/// </summary>
|
/// <typeparam name="T"></typeparam>
|
/// <returns></returns>
|
public static T GetTestItemByProduct<T>(string product) where T : IList<TestItemData>
|
{
|
string path = Path.Combine(TestItem.FileFolder, $"TestItem_{product}.setting");
|
if (!File.Exists(path)) return default(T);
|
T datas = XmlHelper.DeserializeFromXml<T>(path);
|
return datas;
|
}
|
|
/// <summary>
|
/// 根据产品保存测试项
|
/// </summary>
|
/// <param name="datas"></param>
|
/// <exception cref="Exception"></exception>
|
public static void SaveTestItemByProduct(string product, IList<TestItemData> datas)
|
{
|
if (datas == null)
|
{
|
throw new Exception("不能为null");
|
}
|
string path = Path.Combine(TestItem.FileFolder, $"TestItem_{product}.setting");
|
XmlHelper.SerializeToXml(path, datas);
|
}
|
|
}
|
}
|