class ServiceCollection
public class ServiceCollection <: List<ServiceDescriptor>功能:表示用于注册服务描述的集合。
父类型:
- List<ServiceDescriptor>
func add(ServiceDescriptor)
public func add(element: ServiceDescriptor): Unit功能:在集合末尾添加一个服务描述。
参数:
- element: ServiceDescriptor - 要添加的服务描述。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func add(Collection<ServiceDescriptor>)
public func add(all: Collection<ServiceDescriptor>): Unit功能:在集合末尾追加多个服务描述。
参数:
- all: Collection<ServiceDescriptor> - 要添加的服务描述集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func add(ServiceDescriptor, Int64)
public func add(element: ServiceDescriptor, at: Int64): Unit功能:在指定位置插入一个服务描述。
参数:
- element: ServiceDescriptor - 要插入的服务描述。
- at:
Int64- 插入位置。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func add(Collection<ServiceDescriptor>, Int64)
public func add(all: Collection<ServiceDescriptor>, at: Int64): Unit功能:在指定位置插入多个服务描述。
参数:
- all: Collection<ServiceDescriptor> - 要插入的服务描述集合。
- at:
Int64- 插入位置。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func remove(Int64)
public func remove(at: Int64): ServiceDescriptor功能:删除指定位置的服务描述。
参数:
- at:
Int64- 要删除的位置。
返回值:
异常:
UnsupportedException- 当服务集合已构建时抛出。
func remove(Range<Int64>)
public func remove(range: Range<Int64>): Unit功能:删除指定范围内的服务描述。
参数:
- range:
Range<Int64>- 要删除的索引范围。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func removeIf((ServiceDescriptor) -> Bool)
public func removeIf(predicate: (ServiceDescriptor) -> Bool): Unit功能:删除满足条件的服务描述。
参数:
- predicate: (ServiceDescriptor) -> Bool - 用于判断是否删除的条件函数。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func isEmpty()
public func isEmpty(): Bool功能:检查集合是否为空。
返回值:
Bool- 如果集合中没有服务描述则返回true,否则返回false。
func clear()
public func clear(): Unit功能:清空当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func get(Int64)
public func get(index: Int64): ?ServiceDescriptor功能:返回指定位置的服务描述。
参数:
- index:
Int64- 要读取的索引位置。
返回值:
- ?ServiceDescriptor - 指定位置的服务描述。
prop first
public prop first: ?ServiceDescriptor功能:返回集合中的第一个服务描述。
prop last
public prop last: ?ServiceDescriptor功能:返回集合中的最后一个服务描述。
prop size
public prop size: Int64功能:返回集合中的服务描述数量。
类型:Int64
func toArray()
public func toArray(): Array<ServiceDescriptor>功能:将当前服务集合转换为数组。
返回值:
- Array<ServiceDescriptor> - 包含全部服务描述的数组副本。
func iterator()
public func iterator(): Iterator<ServiceDescriptor>功能:返回遍历当前服务集合的迭代器。
返回值:
- Iterator<ServiceDescriptor> - 当前服务集合的迭代器。
operator []
public operator func [](index: Int64): ServiceDescriptor功能:读取指定索引位置的服务描述。
参数:
- index:
Int64- 要读取的索引位置。
返回值:
- ServiceDescriptor - 指定索引位置的服务描述。
operator []
public operator func [](index: Int64, value: ServiceDescriptor): Unit功能:设置指定索引位置的服务描述。
参数:
- index:
Int64- 要写入的索引位置。 - value: ServiceDescriptor - 要设置的服务描述。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func build()
public func build(): IServiceProvider功能:使用默认选项构建服务提供者。
返回值:
- IServiceProvider - 构建得到的服务提供者。
异常:
Exception- 当构建或校验服务图失败时抛出。
func build((ServiceProviderOptions) -> Unit)
public func build(configureOptions: (ServiceProviderOptions) -> Unit): IServiceProvider功能:使用自定义选项构建服务提供者。
参数:
- configureOptions: (ServiceProviderOptions) -> Unit - 用于配置服务提供者选项的回调。
返回值:
- IServiceProvider - 构建得到的服务提供者。
异常:
Exception- 当构建或校验服务图失败时抛出。
扩展成员
func tryAdd(ServiceDescriptor)
public func tryAdd(element: ServiceDescriptor): Unit功能:仅当相同服务类型和服务键尚未注册时添加服务描述。
来源扩展:extend ServiceCollection
参数:
- element: ServiceDescriptor - 要尝试添加的服务描述。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addSingleton(TService)
public func addSingleton<TService>(instance: TService): ServiceCollection功能:注册一个单例实例。
来源扩展:extend ServiceCollection
参数:
- instance:
TService- 要注册的单例实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addSingleton(TImplementation)
public func addSingleton<TService, TImplementation>(instance: TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现实例的单例。
来源扩展:extend ServiceCollection
参数:
- instance:
TImplementation- 要注册的实现实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addSingleton()
public func addSingleton<TService, TImplementation>(): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的单例映射。
来源扩展:extend ServiceCollection
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addSingleton((IServiceProvider) -> TService)
public func addSingleton<TService>(factory: (IServiceProvider) -> TService): ServiceCollection功能:注册一个单例工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TService - 用于创建单例实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addSingleton((IServiceProvider) -> TImplementation)
public func addSingleton<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的单例工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addSingleton(TypeInfo)
public func addSingleton(serviceType: TypeInfo): ServiceCollection功能:将指定运行时类型按自身类型注册为单例。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addSingleton(TypeInfo, TypeInfo)
public func addSingleton(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:将指定运行时类型按单例映射方式注册。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddSingleton(TService)
public func tryAddSingleton<TService>(instance: TService): ServiceCollection where TService <: Object功能:仅当服务尚未注册时添加一个单例实例。
来源扩展:extend ServiceCollection
参数:
- instance:
TService- 要注册的单例实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddSingleton()
public func tryAddSingleton<TService, TImplementation>(): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个单例类型映射。
来源扩展:extend ServiceCollection
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddSingleton(TImplementation)
public func tryAddSingleton<TService, TImplementation>(instance: TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现实例的单例。
来源扩展:extend ServiceCollection
参数:
- instance:
TImplementation- 要注册的实现实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddSingleton((IServiceProvider) -> TService)
public func tryAddSingleton<TService>(factory: (IServiceProvider) -> TService): ServiceCollection功能:仅当服务尚未注册时添加一个单例工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TService - 用于创建单例实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddSingleton((IServiceProvider) -> TImplementation)
public func tryAddSingleton<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现类型的单例工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddSingleton(TypeInfo)
public func tryAddSingleton(serviceType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按自身类型添加单例。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddSingleton(TypeInfo, TypeInfo)
public func tryAddSingleton(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按运行时类型添加单例映射。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addScoped()
public func addScoped<TService, TImplementation>(): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的作用域映射。
来源扩展:extend ServiceCollection
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addScoped((IServiceProvider) -> TService)
public func addScoped<TService>(factory: (IServiceProvider) -> TService): ServiceCollection功能:注册一个作用域工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addScoped((IServiceProvider) -> TImplementation)
public func addScoped<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的作用域工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addScoped(TypeInfo)
public func addScoped(serviceType: TypeInfo): ServiceCollection功能:将指定运行时类型按自身类型注册为作用域服务。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addScoped(TypeInfo, TypeInfo)
public func addScoped(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:将指定运行时类型按作用域映射方式注册。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddScoped()
public func tryAddScoped<TService, TImplementation>(): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个作用域类型映射。
来源扩展:extend ServiceCollection
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddScoped((IServiceProvider) -> TService)
public func tryAddScoped<TService>(factory: (IServiceProvider) -> TService): ServiceCollection功能:仅当服务尚未注册时添加一个作用域工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddScoped((IServiceProvider) -> TImplementation)
public func tryAddScoped<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现类型的作用域工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddScoped(TypeInfo)
public func tryAddScoped(serviceType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按自身类型添加作用域服务。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddScoped(TypeInfo, TypeInfo)
public func tryAddScoped(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按运行时类型添加作用域映射。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addTransient()
public func addTransient<TService, TImplementation>(): ServiceCollection功能:注册一个指定服务类型和实现类型的瞬时映射。
来源扩展:extend ServiceCollection
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addTransient((IServiceProvider) -> TService)
public func addTransient<TService>(factory: (IServiceProvider) -> TService): ServiceCollection功能:注册一个瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TService - 用于创建瞬时实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addTransient((IServiceProvider) -> TImplementation)
public func addTransient<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addTransient(TypeInfo)
public func addTransient(serviceType: TypeInfo): ServiceCollection功能:将指定运行时类型按自身类型注册为瞬时服务。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addTransient(TypeInfo, TypeInfo)
public func addTransient(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:将指定运行时类型按瞬时映射方式注册。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddTransient()
public func tryAddTransient<TService, TImplementation>(): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个瞬时类型映射。
来源扩展:extend ServiceCollection
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddTransient((IServiceProvider) -> TService)
public func tryAddTransient<TService>(factory: (IServiceProvider) -> TService): ServiceCollection功能:仅当服务尚未注册时添加一个瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TService - 用于创建瞬时实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddTransient((IServiceProvider) -> TImplementation)
public func tryAddTransient<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现类型的瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddTransient(TypeInfo)
public func tryAddTransient(serviceType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按自身类型添加瞬时服务。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddTransient(TypeInfo, TypeInfo)
public func tryAddTransient(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按运行时类型添加瞬时映射。
来源扩展:extend ServiceCollection
参数:
- serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddEnumerable(ServiceDescriptor)
public func tryAddEnumerable(descriptor: ServiceDescriptor): ServiceCollection功能:仅当相同服务类型、实现类型和服务键尚未注册时添加服务描述。
来源扩展:extend ServiceCollection
参数:
- descriptor: ServiceDescriptor - 要尝试添加的服务描述。
返回值:
- ServiceCollection - 当前服务集合。
异常:
IllegalArgumentException- 当实现类型与服务类型不可区分时抛出。UnsupportedException- 当服务集合已构建时抛出。
func tryAddEnumerable(Collection<ServiceDescriptor>)
public func tryAddEnumerable(descriptors: Collection<ServiceDescriptor>): ServiceCollection功能:仅当各项描述尚未重复注册时批量添加服务描述。
来源扩展:extend ServiceCollection
参数:
- descriptors: Collection<ServiceDescriptor> - 要尝试添加的服务描述集合。
返回值:
- ServiceCollection - 当前服务集合。
异常:
IllegalArgumentException- 当某项实现类型与服务类型不可区分时抛出。UnsupportedException- 当服务集合已构建时抛出。
func addKeyedSingleton(String, TService)
public func addKeyedSingleton<TService>(serviceKey: String, instance: TService): ServiceCollection功能:注册一个带键的单例实例。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - instance:
TService- 要注册的单例实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedSingleton(String, TImplementation)
public func addKeyedSingleton<TService, TImplementation>(serviceKey: String, instance: TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现实例的带键单例。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - instance:
TImplementation- 要注册的实现实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedSingleton(String)
public func addKeyedSingleton<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的带键单例映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedSingleton(String, (IServiceProvider) -> TService)
public func addKeyedSingleton<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection功能:注册一个带键的单例工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TService - 用于创建单例实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedSingleton(String, (IServiceProvider) -> TImplementation)
public func addKeyedSingleton<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的带键单例工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedSingleton(String, TypeInfo)
public func addKeyedSingleton(serviceKey: String, serviceType: TypeInfo): ServiceCollection功能:将指定运行时类型按自身类型注册为带键单例。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedSingleton(String, TypeInfo, TypeInfo)
public func addKeyedSingleton(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:将指定运行时类型按带键单例映射方式注册。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedSingleton(String, TService)
public func tryAddKeyedSingleton<TService>(serviceKey: String, instance: TService): ServiceCollection where TService <: Object功能:仅当服务尚未注册时添加一个带键单例实例。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - instance:
TService- 要注册的单例实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedSingleton(String)
public func tryAddKeyedSingleton<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个带键单例类型映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedSingleton(String, TImplementation)
public func tryAddKeyedSingleton<TService, TImplementation>(serviceKey: String, instance: TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现实例的带键单例。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - instance:
TImplementation- 要注册的实现实例。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedSingleton(String, (IServiceProvider) -> TService)
public func tryAddKeyedSingleton<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection功能:仅当服务尚未注册时添加一个带键单例工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TService - 用于创建单例实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedSingleton(String, (IServiceProvider) -> TImplementation)
public func tryAddKeyedSingleton<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现类型的带键单例工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedSingleton(String, TypeInfo)
public func tryAddKeyedSingleton(serviceKey: String, serviceType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按自身类型添加带键单例。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedSingleton(String, TypeInfo, TypeInfo)
public func tryAddKeyedSingleton(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按运行时类型添加带键单例映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedScoped(String)
public func addKeyedScoped<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的带键作用域映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedScoped(String, (IServiceProvider) -> TService)
public func addKeyedScoped<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection功能:注册一个带键的作用域工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedScoped(String, (IServiceProvider) -> TImplementation)
public func addKeyedScoped<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的带键作用域工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedScoped(String, TypeInfo)
public func addKeyedScoped(serviceKey: String, serviceType: TypeInfo): ServiceCollection功能:将指定运行时类型按自身类型注册为带键作用域服务。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedScoped(String, TypeInfo, TypeInfo)
public func addKeyedScoped(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:将指定运行时类型按带键作用域映射方式注册。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedScoped(String)
public func tryAddKeyedScoped<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个带键作用域类型映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedScoped(String, (IServiceProvider) -> TService)
public func tryAddKeyedScoped<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection功能:仅当服务尚未注册时添加一个带键作用域工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedScoped(String, (IServiceProvider) -> TImplementation)
public func tryAddKeyedScoped<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现类型的带键作用域工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedScoped(String, TypeInfo)
public func tryAddKeyedScoped(serviceKey: String, serviceType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按自身类型添加带键作用域服务。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedScoped(String, TypeInfo, TypeInfo)
public func tryAddKeyedScoped(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按运行时类型添加带键作用域映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedTransient(String)
public func addKeyedTransient<TService, TImplementation>(serviceKey: String): ServiceCollection功能:注册一个指定服务类型和实现类型的带键瞬时映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedTransient(String, (IServiceProvider) -> TService)
public func addKeyedTransient<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection功能:注册一个带键的瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TService - 用于创建瞬时实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedTransient(String, (IServiceProvider) -> TImplementation)
public func addKeyedTransient<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:注册一个指定服务类型和实现类型的带键瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedTransient(String, TypeInfo)
public func addKeyedTransient(serviceKey: String, serviceType: TypeInfo): ServiceCollection功能:将指定运行时类型按自身类型注册为带键瞬时服务。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func addKeyedTransient(String, TypeInfo, TypeInfo)
public func addKeyedTransient(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:将指定运行时类型按带键瞬时映射方式注册。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedTransient(String)
public func tryAddKeyedTransient<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个带键瞬时类型映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedTransient(String, (IServiceProvider) -> TService)
public func tryAddKeyedTransient<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection功能:仅当服务尚未注册时添加一个带键瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TService - 用于创建瞬时实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedTransient(String, (IServiceProvider) -> TImplementation)
public func tryAddKeyedTransient<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object功能:仅当服务尚未注册时添加一个指定实现类型的带键瞬时工厂。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedTransient(String, TypeInfo)
public func tryAddKeyedTransient(serviceKey: String, serviceType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按自身类型添加带键瞬时服务。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。
func tryAddKeyedTransient(String, TypeInfo, TypeInfo)
public func tryAddKeyedTransient(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection功能:仅当服务尚未注册时按运行时类型添加带键瞬时映射。
来源扩展:extend ServiceCollection
参数:
- serviceKey:
String- 要绑定的服务键。 - serviceType:
TypeInfo- 要注册的服务类型。 - implementationType:
TypeInfo- 对应的实现类型。
返回值:
- ServiceCollection - 当前服务集合。
异常:
UnsupportedException- 当服务集合已构建时抛出。