🍒 fix(LazyServer): 修复懒加载服务异常
This commit is contained in:
parent
a91dd7f134
commit
5beb7d7027
@ -11,7 +11,7 @@ namespace Admin.NET.Core;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class LazyHelper
|
public class LazyHelper
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<Type, Lazy<object>> Cache = new();
|
private static readonly ConcurrentDictionary<Type, dynamic> Cache = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取服务
|
/// 获取服务
|
||||||
@ -22,8 +22,7 @@ public class LazyHelper
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var lazy = Cache.GetOrAdd(typeof(T), _ => new Lazy<object>(() => App.GetService<T>()));
|
return Cache.GetOrAdd(typeof(T), _ => new Lazy<T>(() => App.GetService<T>()));
|
||||||
return (Lazy<T>)(object)lazy;
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user