You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
507 lines
26 KiB
507 lines
26 KiB
//
|
|
// Copyright © 2019 Swinject Contributors. All rights reserved.
|
|
//
|
|
|
|
//
|
|
// NOTICE:
|
|
//
|
|
// Container.Arguments.swift is generated from Container.Arguments.erb by ERB.
|
|
// Do NOT modify Container.Arguments.swift directly.
|
|
// Instead, modify Container.Arguments.erb and run `script/gencode` at the project root directory to generate the code.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
// MARK: - Registeration with Arguments
|
|
|
|
extension Container {
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 1 argument to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 2 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 3 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2, Arg3>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2, Arg3) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 4 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2, Arg3, Arg4>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 5 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 6 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 7 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 8 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
|
|
/// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to register.
|
|
/// - name: A registration name, which is used to differentiate from other registrations
|
|
/// that have the same service and factory types.
|
|
/// - factory: The closure to specify how the service type is resolved with the dependencies of the type.
|
|
/// It is invoked when the `Container` needs to instantiate the instance.
|
|
/// It takes a `Resolver` instance and 9 arguments to inject dependencies to the instance,
|
|
/// and returns the instance of the component type for the service.
|
|
///
|
|
/// - Returns: A registered `ServiceEntry` to configure more settings with method chaining.
|
|
@discardableResult
|
|
public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(
|
|
_ serviceType: Service.Type,
|
|
name: String? = nil,
|
|
factory: @escaping (Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) -> Service
|
|
) -> ServiceEntry<Service> {
|
|
return _register(serviceType, factory: factory, name: name)
|
|
}
|
|
}
|
|
|
|
// MARK: - Resolver with Arguments
|
|
|
|
extension Container {
|
|
/// Retrieves the instance with the specified service type and 1 argument to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - argument: 1 argument to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and 1 argument is found in the `Container`.
|
|
public func resolve<Service, Arg1>(
|
|
_ serviceType: Service.Type,
|
|
argument: Arg1
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, argument: argument)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, 1 argument to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - argument: 1 argument to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// 1 argument and name is found in the `Container`.
|
|
public func resolve<Service, Arg1>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
argument: Arg1
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, argument)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 2 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 2 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 2 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 2 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 2 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 2 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 3 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 3 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 3 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2, arg3)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 3 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 3 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 3 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2, Arg3)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2, arg3)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 4 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 4 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 4 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2, arg3, arg4)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 4 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 4 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 4 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2, Arg3, Arg4)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2, arg3, arg4)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 5 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 5 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 5 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2, arg3, arg4, arg5)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 5 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 5 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 5 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2, Arg3, Arg4, Arg5)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2, arg3, arg4, arg5)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 6 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 6 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 6 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2, arg3, arg4, arg5, arg6)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 6 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 6 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 6 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2, arg3, arg4, arg5, arg6)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 7 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 7 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 7 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 7 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 7 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 7 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2, arg3, arg4, arg5, arg6, arg7)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 8 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 8 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 8 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7, _ arg8: Arg8
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 8 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 8 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 8 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7, _ arg8: Arg8
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)) }
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type and list of 9 arguments to the factory closure.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - arguments: List of 9 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type
|
|
/// and list of 9 arguments is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(
|
|
_ serviceType: Service.Type,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7, _ arg8: Arg8, _ arg9: Arg9
|
|
) -> Service? {
|
|
return resolve(serviceType, name: nil, arguments: arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
|
|
}
|
|
|
|
/// Retrieves the instance with the specified service type, list of 9 arguments to the factory closure and registration name.
|
|
///
|
|
/// - Parameters:
|
|
/// - serviceType: The service type to resolve.
|
|
/// - name: The registration name.
|
|
/// - arguments: List of 9 arguments to pass to the factory closure.
|
|
///
|
|
/// - Returns: The resolved service type instance, or nil if no registration for the service type,
|
|
/// list of 9 arguments and name is found in the `Container`.
|
|
public func resolve<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>(
|
|
_: Service.Type,
|
|
name: String?,
|
|
arguments arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7, _ arg8: Arg8, _ arg9: Arg9
|
|
) -> Service? {
|
|
typealias FactoryType = ((Resolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9)) -> Any
|
|
return _resolve(name: name) { (factory: FactoryType) in factory((self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)) }
|
|
}
|
|
}
|