using JiShe.IoT.CommonServices.Dto; using JiShe.ServicePro.Commons; using JiShe.ServicePro.Core; using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; using static FreeSql.Internal.GlobalFilter; namespace JiShe.IoT.CommonServices { public class CommonService : IoTAppService, ICommonService { private static ConcurrentDictionary> _selectListType = new(); /// /// 初始化所有固定的枚举下拉框字典 /// /// 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) { SelectResultAttribute[] selectResultAttribute = (SelectResultAttribute[])typeInfoItem.GetCustomAttributes(typeof(SelectResultAttribute), false); _selectListType.TryAdd(typeInfoItem.Name, CommonHelper.GetTypeAttributeList(typeInfoItem, selectResultAttribute[0].IsGetPropertie)); } } /// /// 根据type名称获取下拉框数据,主要是枚举等 /// /// /// public List GetSelectResultList(SelectResultListInput input) { List selectResults = _selectListType.TryGetValue(input.TypeName, out var list) ? list : new List(); return selectResults; } } }