Skip to content

class ServiceCollection

cangjie
public class ServiceCollection <: List<ServiceDescriptor>

功能:表示用于注册服务描述的集合。

父类型:

func add(ServiceDescriptor)

cangjie
public func add(element: ServiceDescriptor): Unit

功能:在集合末尾添加一个服务描述。

参数:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func add(Collection<ServiceDescriptor>)

cangjie
public func add(all: Collection<ServiceDescriptor>): Unit

功能:在集合末尾追加多个服务描述。

参数:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func add(ServiceDescriptor, Int64)

cangjie
public func add(element: ServiceDescriptor, at: Int64): Unit

功能:在指定位置插入一个服务描述。

参数:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func add(Collection<ServiceDescriptor>, Int64)

cangjie
public func add(all: Collection<ServiceDescriptor>, at: Int64): Unit

功能:在指定位置插入多个服务描述。

参数:

  • all: Collection<ServiceDescriptor> - 要插入的服务描述集合。
  • at: Int64 - 插入位置。

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func remove(Int64)

cangjie
public func remove(at: Int64): ServiceDescriptor

功能:删除指定位置的服务描述。

参数:

  • at: Int64 - 要删除的位置。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func remove(Range<Int64>)

cangjie
public func remove(range: Range<Int64>): Unit

功能:删除指定范围内的服务描述。

参数:

  • range: Range<Int64> - 要删除的索引范围。

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func removeIf((ServiceDescriptor) -> Bool)

cangjie
public func removeIf(predicate: (ServiceDescriptor) -> Bool): Unit

功能:删除满足条件的服务描述。

参数:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func isEmpty()

cangjie
public func isEmpty(): Bool

功能:检查集合是否为空。

返回值:

  • Bool - 如果集合中没有服务描述则返回 true,否则返回 false

func clear()

cangjie
public func clear(): Unit

功能:清空当前服务集合。

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func get(Int64)

cangjie
public func get(index: Int64): ?ServiceDescriptor

功能:返回指定位置的服务描述。

参数:

  • index: Int64 - 要读取的索引位置。

返回值:

prop first

cangjie
public prop first: ?ServiceDescriptor

功能:返回集合中的第一个服务描述。

类型:?ServiceDescriptor

prop last

cangjie
public prop last: ?ServiceDescriptor

功能:返回集合中的最后一个服务描述。

类型:?ServiceDescriptor

prop size

cangjie
public prop size: Int64

功能:返回集合中的服务描述数量。

类型:Int64

func toArray()

cangjie
public func toArray(): Array<ServiceDescriptor>

功能:将当前服务集合转换为数组。

返回值:

func iterator()

cangjie
public func iterator(): Iterator<ServiceDescriptor>

功能:返回遍历当前服务集合的迭代器。

返回值:

operator []

cangjie
public operator func [](index: Int64): ServiceDescriptor

功能:读取指定索引位置的服务描述。

参数:

  • index: Int64 - 要读取的索引位置。

返回值:

operator []

cangjie
public operator func [](index: Int64, value: ServiceDescriptor): Unit

功能:设置指定索引位置的服务描述。

参数:

  • index: Int64 - 要写入的索引位置。
  • value: ServiceDescriptor - 要设置的服务描述。

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func build()

cangjie
public func build(): IServiceProvider

功能:使用默认选项构建服务提供者。

返回值:

异常:

  • Exception - 当构建或校验服务图失败时抛出。

func build((ServiceProviderOptions) -> Unit)

cangjie
public func build(configureOptions: (ServiceProviderOptions) -> Unit): IServiceProvider

功能:使用自定义选项构建服务提供者。

参数:

返回值:

异常:

  • Exception - 当构建或校验服务图失败时抛出。

扩展成员

func tryAdd(ServiceDescriptor)

cangjie
public func tryAdd(element: ServiceDescriptor): Unit

功能:仅当相同服务类型和服务键尚未注册时添加服务描述。

来源扩展:extend ServiceCollection

参数:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addSingleton(TService)

cangjie
public func addSingleton<TService>(instance: TService): ServiceCollection

功能:注册一个单例实例。

来源扩展:extend ServiceCollection

参数:

  • instance: TService - 要注册的单例实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addSingleton(TImplementation)

cangjie
public func addSingleton<TService, TImplementation>(instance: TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现实例的单例。

来源扩展:extend ServiceCollection

参数:

  • instance: TImplementation - 要注册的实现实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addSingleton()

cangjie
public func addSingleton<TService, TImplementation>(): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的单例映射。

来源扩展:extend ServiceCollection

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addSingleton((IServiceProvider) -> TService)

cangjie
public func addSingleton<TService>(factory: (IServiceProvider) -> TService): ServiceCollection

功能:注册一个单例工厂。

来源扩展:extend ServiceCollection

参数:

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addSingleton((IServiceProvider) -> TImplementation)

cangjie
public func addSingleton<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的单例工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addSingleton(TypeInfo)

cangjie
public func addSingleton(serviceType: TypeInfo): ServiceCollection

功能:将指定运行时类型按自身类型注册为单例。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addSingleton(TypeInfo, TypeInfo)

cangjie
public func addSingleton(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:将指定运行时类型按单例映射方式注册。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddSingleton(TService)

cangjie
public func tryAddSingleton<TService>(instance: TService): ServiceCollection where TService <: Object

功能:仅当服务尚未注册时添加一个单例实例。

来源扩展:extend ServiceCollection

参数:

  • instance: TService - 要注册的单例实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddSingleton()

cangjie
public func tryAddSingleton<TService, TImplementation>(): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个单例类型映射。

来源扩展:extend ServiceCollection

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddSingleton(TImplementation)

cangjie
public func tryAddSingleton<TService, TImplementation>(instance: TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现实例的单例。

来源扩展:extend ServiceCollection

参数:

  • instance: TImplementation - 要注册的实现实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddSingleton((IServiceProvider) -> TService)

cangjie
public func tryAddSingleton<TService>(factory: (IServiceProvider) -> TService): ServiceCollection

功能:仅当服务尚未注册时添加一个单例工厂。

来源扩展:extend ServiceCollection

参数:

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddSingleton((IServiceProvider) -> TImplementation)

cangjie
public func tryAddSingleton<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现类型的单例工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddSingleton(TypeInfo)

cangjie
public func tryAddSingleton(serviceType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按自身类型添加单例。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddSingleton(TypeInfo, TypeInfo)

cangjie
public func tryAddSingleton(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按运行时类型添加单例映射。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addScoped()

cangjie
public func addScoped<TService, TImplementation>(): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的作用域映射。

来源扩展:extend ServiceCollection

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addScoped((IServiceProvider) -> TService)

cangjie
public func addScoped<TService>(factory: (IServiceProvider) -> TService): ServiceCollection

功能:注册一个作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addScoped((IServiceProvider) -> TImplementation)

cangjie
public func addScoped<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addScoped(TypeInfo)

cangjie
public func addScoped(serviceType: TypeInfo): ServiceCollection

功能:将指定运行时类型按自身类型注册为作用域服务。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addScoped(TypeInfo, TypeInfo)

cangjie
public func addScoped(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:将指定运行时类型按作用域映射方式注册。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddScoped()

cangjie
public func tryAddScoped<TService, TImplementation>(): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个作用域类型映射。

来源扩展:extend ServiceCollection

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddScoped((IServiceProvider) -> TService)

cangjie
public func tryAddScoped<TService>(factory: (IServiceProvider) -> TService): ServiceCollection

功能:仅当服务尚未注册时添加一个作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddScoped((IServiceProvider) -> TImplementation)

cangjie
public func tryAddScoped<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现类型的作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddScoped(TypeInfo)

cangjie
public func tryAddScoped(serviceType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按自身类型添加作用域服务。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddScoped(TypeInfo, TypeInfo)

cangjie
public func tryAddScoped(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按运行时类型添加作用域映射。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addTransient()

cangjie
public func addTransient<TService, TImplementation>(): ServiceCollection

功能:注册一个指定服务类型和实现类型的瞬时映射。

来源扩展:extend ServiceCollection

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addTransient((IServiceProvider) -> TService)

cangjie
public func addTransient<TService>(factory: (IServiceProvider) -> TService): ServiceCollection

功能:注册一个瞬时工厂。

来源扩展:extend ServiceCollection

参数:

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addTransient((IServiceProvider) -> TImplementation)

cangjie
public func addTransient<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的瞬时工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addTransient(TypeInfo)

cangjie
public func addTransient(serviceType: TypeInfo): ServiceCollection

功能:将指定运行时类型按自身类型注册为瞬时服务。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addTransient(TypeInfo, TypeInfo)

cangjie
public func addTransient(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:将指定运行时类型按瞬时映射方式注册。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddTransient()

cangjie
public func tryAddTransient<TService, TImplementation>(): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个瞬时类型映射。

来源扩展:extend ServiceCollection

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddTransient((IServiceProvider) -> TService)

cangjie
public func tryAddTransient<TService>(factory: (IServiceProvider) -> TService): ServiceCollection

功能:仅当服务尚未注册时添加一个瞬时工厂。

来源扩展:extend ServiceCollection

参数:

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddTransient((IServiceProvider) -> TImplementation)

cangjie
public func tryAddTransient<TService, TImplementation>(factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现类型的瞬时工厂。

来源扩展:extend ServiceCollection

参数:

  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddTransient(TypeInfo)

cangjie
public func tryAddTransient(serviceType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按自身类型添加瞬时服务。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddTransient(TypeInfo, TypeInfo)

cangjie
public func tryAddTransient(serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按运行时类型添加瞬时映射。

来源扩展:extend ServiceCollection

参数:

  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddEnumerable(ServiceDescriptor)

cangjie
public func tryAddEnumerable(descriptor: ServiceDescriptor): ServiceCollection

功能:仅当相同服务类型、实现类型和服务键尚未注册时添加服务描述。

来源扩展:extend ServiceCollection

参数:

返回值:

异常:

  • IllegalArgumentException - 当实现类型与服务类型不可区分时抛出。
  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddEnumerable(Collection<ServiceDescriptor>)

cangjie
public func tryAddEnumerable(descriptors: Collection<ServiceDescriptor>): ServiceCollection

功能:仅当各项描述尚未重复注册时批量添加服务描述。

来源扩展:extend ServiceCollection

参数:

返回值:

异常:

  • IllegalArgumentException - 当某项实现类型与服务类型不可区分时抛出。
  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedSingleton(String, TService)

cangjie
public func addKeyedSingleton<TService>(serviceKey: String, instance: TService): ServiceCollection

功能:注册一个带键的单例实例。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • instance: TService - 要注册的单例实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedSingleton(String, TImplementation)

cangjie
public func addKeyedSingleton<TService, TImplementation>(serviceKey: String, instance: TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现实例的带键单例。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • instance: TImplementation - 要注册的实现实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedSingleton(String)

cangjie
public func addKeyedSingleton<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的带键单例映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedSingleton(String, (IServiceProvider) -> TService)

cangjie
public func addKeyedSingleton<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection

功能:注册一个带键的单例工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TService - 用于创建单例实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedSingleton(String, (IServiceProvider) -> TImplementation)

cangjie
public func addKeyedSingleton<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的带键单例工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedSingleton(String, TypeInfo)

cangjie
public func addKeyedSingleton(serviceKey: String, serviceType: TypeInfo): ServiceCollection

功能:将指定运行时类型按自身类型注册为带键单例。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedSingleton(String, TypeInfo, TypeInfo)

cangjie
public func addKeyedSingleton(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:将指定运行时类型按带键单例映射方式注册。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedSingleton(String, TService)

cangjie
public func tryAddKeyedSingleton<TService>(serviceKey: String, instance: TService): ServiceCollection where TService <: Object

功能:仅当服务尚未注册时添加一个带键单例实例。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • instance: TService - 要注册的单例实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedSingleton(String)

cangjie
public func tryAddKeyedSingleton<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个带键单例类型映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedSingleton(String, TImplementation)

cangjie
public func tryAddKeyedSingleton<TService, TImplementation>(serviceKey: String, instance: TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现实例的带键单例。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • instance: TImplementation - 要注册的实现实例。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedSingleton(String, (IServiceProvider) -> TService)

cangjie
public func tryAddKeyedSingleton<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection

功能:仅当服务尚未注册时添加一个带键单例工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TService - 用于创建单例实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedSingleton(String, (IServiceProvider) -> TImplementation)

cangjie
public func tryAddKeyedSingleton<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现类型的带键单例工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedSingleton(String, TypeInfo)

cangjie
public func tryAddKeyedSingleton(serviceKey: String, serviceType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按自身类型添加带键单例。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedSingleton(String, TypeInfo, TypeInfo)

cangjie
public func tryAddKeyedSingleton(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按运行时类型添加带键单例映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedScoped(String)

cangjie
public func addKeyedScoped<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的带键作用域映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedScoped(String, (IServiceProvider) -> TService)

cangjie
public func addKeyedScoped<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection

功能:注册一个带键的作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedScoped(String, (IServiceProvider) -> TImplementation)

cangjie
public func addKeyedScoped<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的带键作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedScoped(String, TypeInfo)

cangjie
public func addKeyedScoped(serviceKey: String, serviceType: TypeInfo): ServiceCollection

功能:将指定运行时类型按自身类型注册为带键作用域服务。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedScoped(String, TypeInfo, TypeInfo)

cangjie
public func addKeyedScoped(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:将指定运行时类型按带键作用域映射方式注册。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedScoped(String)

cangjie
public func tryAddKeyedScoped<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个带键作用域类型映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedScoped(String, (IServiceProvider) -> TService)

cangjie
public func tryAddKeyedScoped<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection

功能:仅当服务尚未注册时添加一个带键作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TService - 用于创建作用域实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedScoped(String, (IServiceProvider) -> TImplementation)

cangjie
public func tryAddKeyedScoped<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现类型的带键作用域工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedScoped(String, TypeInfo)

cangjie
public func tryAddKeyedScoped(serviceKey: String, serviceType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按自身类型添加带键作用域服务。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedScoped(String, TypeInfo, TypeInfo)

cangjie
public func tryAddKeyedScoped(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按运行时类型添加带键作用域映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedTransient(String)

cangjie
public func addKeyedTransient<TService, TImplementation>(serviceKey: String): ServiceCollection

功能:注册一个指定服务类型和实现类型的带键瞬时映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedTransient(String, (IServiceProvider) -> TService)

cangjie
public func addKeyedTransient<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection

功能:注册一个带键的瞬时工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TService - 用于创建瞬时实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedTransient(String, (IServiceProvider) -> TImplementation)

cangjie
public func addKeyedTransient<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:注册一个指定服务类型和实现类型的带键瞬时工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedTransient(String, TypeInfo)

cangjie
public func addKeyedTransient(serviceKey: String, serviceType: TypeInfo): ServiceCollection

功能:将指定运行时类型按自身类型注册为带键瞬时服务。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func addKeyedTransient(String, TypeInfo, TypeInfo)

cangjie
public func addKeyedTransient(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:将指定运行时类型按带键瞬时映射方式注册。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedTransient(String)

cangjie
public func tryAddKeyedTransient<TService, TImplementation>(serviceKey: String): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个带键瞬时类型映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedTransient(String, (IServiceProvider) -> TService)

cangjie
public func tryAddKeyedTransient<TService>(serviceKey: String, factory: (IServiceProvider) -> TService): ServiceCollection

功能:仅当服务尚未注册时添加一个带键瞬时工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TService - 用于创建瞬时实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedTransient(String, (IServiceProvider) -> TImplementation)

cangjie
public func tryAddKeyedTransient<TService, TImplementation>(serviceKey: String, factory: (IServiceProvider) -> TImplementation): ServiceCollection where TImplementation <: Object

功能:仅当服务尚未注册时添加一个指定实现类型的带键瞬时工厂。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • factory: (IServiceProvider) -> TImplementation - 用于创建实现实例的工厂。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedTransient(String, TypeInfo)

cangjie
public func tryAddKeyedTransient(serviceKey: String, serviceType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按自身类型添加带键瞬时服务。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。

func tryAddKeyedTransient(String, TypeInfo, TypeInfo)

cangjie
public func tryAddKeyedTransient(serviceKey: String, serviceType: TypeInfo, implementationType: TypeInfo): ServiceCollection

功能:仅当服务尚未注册时按运行时类型添加带键瞬时映射。

来源扩展:extend ServiceCollection

参数:

  • serviceKey: String - 要绑定的服务键。
  • serviceType: TypeInfo - 要注册的服务类型。
  • implementationType: TypeInfo - 对应的实现类型。

返回值:

异常:

  • UnsupportedException - 当服务集合已构建时抛出。