mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
refactor(ioc): 简化依赖注入容器中的列表初始化语法
- 使用集合表达式替代显式创建List<object>实例 - 统一代码风格,提高可读性 - 减少不必要的类型声明冗余 - [no tag]
This commit is contained in:
parent
b86add9789
commit
5270a19e44
@ -32,7 +32,7 @@ public class IocContainer
|
||||
$"Singleton already registered for type: {type.Name}");
|
||||
}
|
||||
|
||||
_instances[type] = new List<object> { instance! };
|
||||
_instances[type] = [instance!];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -82,7 +82,7 @@ public class IocContainer
|
||||
{
|
||||
if (!_instances.TryGetValue(type, out var list))
|
||||
{
|
||||
list = new List<object>();
|
||||
list = [];
|
||||
_instances[type] = list;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user