手动启动,定时新增字典缓存,避免多次反射影响性能

This commit is contained in:
alex
2023-09-18 15:07:04 +08:00
parent 0ac46b6e65
commit 6cc0529d60
2 changed files with 16 additions and 17 deletions

View File

@@ -62,25 +62,17 @@ namespace Tnb.WarehouseMgr
static BaseWareHouseService()
{
//_stroageMapLazy = new Lazy<Dictionary<string, IWHStorageService>>(() =>
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
foreach (var serviceType in serviceTypes)
{
//Dictionary<string, IWHStorageService> map = new(StringComparer.OrdinalIgnoreCase);
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IWHStorageService).IsAssignableFrom(u)).ToList();
foreach (var serviceType in serviceTypes)
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
if (!callerName.IsNullOrEmpty())
{
var callerName = serviceType.GetCustomAttribute<CallerAttribute>()?.Name ?? string.Empty;
if (!callerName.IsNullOrEmpty())
{
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
if (obj == null) continue;
_storeMap[callerName] = obj;
}
var obj = Activator.CreateInstance(serviceType) as IWHStorageService;
if (obj == null) continue;
_storeMap[callerName] = obj;
}
//return map;
}
//);
}
protected Task<ClaimsPrincipal> GetUserIdentity(string? asscessToken = null)