refactor(ioc): 简化依赖注入容器中的列表初始化语法

- 使用集合表达式替代显式创建List<object>实例
- 统一代码风格,提高可读性
- 减少不必要的类型声明冗余
- [no tag]
This commit is contained in:
GeWuYou 2025-12-18 08:35:09 +08:00
parent b86add9789
commit 5270a19e44

View File

@ -32,7 +32,7 @@ public class IocContainer
$"Singleton already registered for type: {type.Name}"); $"Singleton already registered for type: {type.Name}");
} }
_instances[type] = new List<object> { instance! }; _instances[type] = [instance!];
} }
/// <summary> /// <summary>
@ -82,7 +82,7 @@ public class IocContainer
{ {
if (!_instances.TryGetValue(type, out var list)) if (!_instances.TryGetValue(type, out var list))
{ {
list = new List<object>(); list = [];
_instances[type] = list; _instances[type] = list;
} }