Container
public class Container
An IoC container that uses constructor dependency injection to create container components and to resolve dependencies. This container defines the entry and exit points for any Coaty application providing lifecycle management for its components.
-
Gets the identity object of this container. The identity can be initialized in the common configuration option
agentIdentity
.Declaration
Swift
private(set) public var identity: Identity? { get }
-
Gets the runtime object of this container.
Declaration
Swift
private(set) public var runtime: Runtime? { get }
-
Gets the communication manager of this container.
Declaration
Swift
private(set) public var communicationManager: CommunicationManager? { get }
-
Creates and bootstraps a Coaty container by registering and resolving the given components and configuratiuon options.
Declaration
Swift
public static func resolve(components: Components, configuration: Configuration) -> Container
Parameters
components
the components to set up within this container
configuration
the configuration options for the components
-
Dynamically registers and resolves the given controller class with the specified controller config options. The request is silently ignored if the container has already been shut down.
Declaration
Swift
public func registerController(name: String, controllerType: Controller.Type, controllerOptions: ControllerOptions) throws
Parameters
name
the name of the controller class (must match the controller name specified in controller config options)
controllerType
the class type of the controller
controllerOptions
the controller’s configuration options
-
Gets the registered controller of the given name. Returns nil if the controller class type is not registered.
Declaration
Swift
public func getController<C>(name: String) -> C? where C : Controller
Parameters
name
the name of the controller
-
Creates a new array with the results of calling the provided callback function once for each registered controller classType/classInstance pair.
Declaration
Swift
public func mapControllers<T>(_ f: (String, Controller) -> T) -> [T]
Parameters
f
function that produces an element of the new array
-
The exit point for a Coaty applicaton. Releases all registered container components and its associated system resources. This container should no longer be used afterwards.
Declaration
Swift
public func shutdown()