42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
|
|
using JiShe.IoT.CommonServices.Dto;
|
|||
|
|
using JiShe.ServicePro.Commons;
|
|||
|
|
using JiShe.ServicePro.Core;
|
|||
|
|
using System.Collections.Concurrent;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
namespace JiShe.IoT.CommonServices
|
|||
|
|
{
|
|||
|
|
public class CommonService : IoTAppService, ICommonService
|
|||
|
|
{
|
|||
|
|
private static ConcurrentDictionary<string, List<SelectResult>> _selectListType = new();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 初始化所有固定的枚举下拉框字典
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public void InitSelectTypetList()
|
|||
|
|
{
|
|||
|
|
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
|||
|
|
var typeList = assemblies.SelectMany(x => x.GetTypes()).Where(x => x.IsDefined(typeof(SelectResultAttribute), false));
|
|||
|
|
|
|||
|
|
foreach (var typeInfoItem in typeList)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
_selectListType.TryAdd(typeInfoItem.Name, CommonHelper.GetEnumAttributeList(typeInfoItem));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据type名称获取下拉框数据,主要是枚举等
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="input"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<SelectResult> GetSelectResultList(SelectResultListInput input)
|
|||
|
|
{
|
|||
|
|
List<SelectResult> selectResults = _selectListType.TryGetValue(input.TypeName, out var list) ? list : new List<SelectResult>();
|
|||
|
|
|
|||
|
|
return selectResults;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|