AppContext
public class AppContext
The AppContext is the context that wrapped the container.
Most of them provide the same functionality as Containers, but they are
responsible for functions such as Lazy
and Factory
.
-
Shared application context for using container.
Declaration
Swift
public static let shared: AppContext
Return Value
Instance of shared application context.
-
Get container components.
Declaration
Swift
public func getFactory<T>(_ type: T.Type) -> [T]
Parameters
type
Container component type.
Return Value
Instance of container.
-
Load container components.
Declaration
Swift
@discardableResult public func load(_ factories: [ModuleFactory.Type], priority: LoadPriority = .normal) -> AppContext
Parameters
factory
Container components.
priority
Using priority.
Return Value
Instance of shared application context.
-
Load container component.
Declaration
Swift
@discardableResult public func load(_ factory: ModuleFactory, priority: LoadPriority = .normal) -> AppContext
Parameters
factory
Container component.
priority
Using priority.
Return Value
Instance of shared application context.
-
Unload container component.
Declaration
Swift
@discardableResult public func unload(_ factory: ModuleFactory) -> AppContext
Parameters
factory
Container component.
Return Value
Instance of shared application context.
-
Unload all container components.
Declaration
Swift
public func unloadAll()
-
Reset container components.
Declaration
Swift
public func reset()
-
Get instance from string class.
Declaration
Swift
public func get<T>( _ type: T.Type, className: String, qualifier: String = "", resolveRole: ResolveRole = .recursive ) -> T?
Parameters
type
The dependency type to resolve.
className
The dependency class name to resolve.
qualifier
The registered qualifier.
resolveRole
The resolve role(default: recursive)
Return Value
The resolved instance, or nil.
-
Get instance from string class by factory.
Declaration
Swift
public func get<T: Factory>( _ type: T.Type, className: String, payload: T.RawPayload, resolveRole: ResolveRole = .recursive ) -> T?
Parameters
type
The dependency type to resolve.
className
The dependency class name to resolve.
payload
User data for resolve.
resolveRole
The resolve role(default: recursive)
Return Value
The resolved instance, or nil.
-
Get instance from string class without resolve. It is used to avoid repetitive resolve if already registered.
Declaration
Swift
public func get<T>( withoutResolve type: T.Type, className: String, qualifier: String, resolveRole: ResolveRole = .recursive ) -> T?
Parameters
type
The dependency type to resolve.
className
The dependency class name to resolve.
qualifier
The registered qualifier.
resolveRole
The resolve role(default: recursive)
Return Value
The resolved instances, or nil.
-
Get instance for type.
Declaration
Swift
public func get<T>( _ type: T.Type, qualifier: String = "", resolveRole: ResolveRole = .recursive ) -> T?
Parameters
type
The dependency type to resolve.
qualifier
The registered qualifier.
resolveRole
The resolve role(default: recursive)
Return Value
The resolved instance, or nil.
-
Get instance list for type.
Declaration
Swift
public func get<T>( _ type: [T].Type, qualifier: String = "", resolveRole: ResolveRole = .default ) -> [T]
Parameters
type
The dependency type to resolve.
qualifier
The registered qualifier.
resolveRole
The resolve role.
Return Value
The resolved instances, or empty.
-
Get instance for type by factory.
Declaration
Swift
public func get<T: Factory>( _ type: T.Type, payload: T.RawPayload, resolveRole: ResolveRole = .recursive ) -> T?
Parameters
type
The dependency type to resolve.
payload
User data for resolve.
resolveRole
The resolve role(default: recursive)
Return Value
The resolved instance, or nil.
-
Get instance list for type by factory.
Declaration
Swift
public func get<T: Factory>( _ type: [T].Type, payload: T.RawPayload, resolveRole: ResolveRole = .default ) -> [T]
Parameters
type
The dependency type to resolve.
payload
User data for resolve.
resolveRole
The resolve role.
Return Value
The resolved instances, or emtpy.
-
Get instance for type without resolve. It is used to avoid repetitive resolve if already registered.
Declaration
Swift
public func get<T>( withoutResolve type: T.Type, qualifier: String, resolveRole: ResolveRole = .recursive ) -> T?
Parameters
type
The dependency type to resolve.
qualifier
The registered qualifier.
resolveRole
The resolve role(default: recursive)
Return Value
The resolved instances, or nil.
-
Get instance list for type without resolve. It is used to avoid repetitive resolve if already registered.
Declaration
Swift
public func get<T>( withoutResolve type: [T].Type, qualifier: String, resolveRole: ResolveRole = .default ) -> [T]
Parameters
type
The dependency type to resolve.
qualifier
The registered qualifier.
resolveRole
The resolve role.
Return Value
The resolved instances, or empty.
-
Load common property.
Declaration
Swift
public func loadProperty(_ properties: [String : Any])
Parameters
properties
Properties.
-
Get property.
Declaration
Swift
public func getProperty(_ path: String, resolveRole: ResolveRole = .default) -> Any?
Parameters
path
Property path.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of String type.
Declaration
Swift
public func getProperty(_ path: String, type: String.Type, resolveRole: ResolveRole = .default) -> String?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Bool type.
Declaration
Swift
public func getProperty(_ path: String, type: Bool.Type, resolveRole: ResolveRole = .default) -> Bool?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Double type.
Declaration
Swift
public func getProperty(_ path: String, type: Double.Type, resolveRole: ResolveRole = .default) -> Double?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Float type.
Declaration
Swift
public func getProperty(_ path: String, type: Float.Type, resolveRole: ResolveRole = .default) -> Float?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Int type.
Declaration
Swift
public func getProperty(_ path: String, type: Int.Type, resolveRole: ResolveRole = .default) -> Int?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Int8 type.
Declaration
Swift
public func getProperty(_ path: String, type: Int8.Type, resolveRole: ResolveRole = .default) -> Int8?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Int16 type.
Declaration
Swift
public func getProperty(_ path: String, type: Int16.Type, resolveRole: ResolveRole = .default) -> Int16?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Int32 type.
Declaration
Swift
public func getProperty(_ path: String, type: Int32.Type, resolveRole: ResolveRole = .default) -> Int32?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of Int64 type.
Declaration
Swift
public func getProperty(_ path: String, type: Int64.Type, resolveRole: ResolveRole = .default) -> Int64?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of UInt type.
Declaration
Swift
public func getProperty(_ path: String, type: UInt.Type, resolveRole: ResolveRole = .default) -> UInt?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of UInt8 type.
Declaration
Swift
public func getProperty(_ path: String, type: UInt8.Type, resolveRole: ResolveRole = .default) -> UInt8?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of UInt16 type.
Declaration
Swift
public func getProperty(_ path: String, type: UInt16.Type, resolveRole: ResolveRole = .default) -> UInt16?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of UInt32 type.
Declaration
Swift
public func getProperty(_ path: String, type: UInt32.Type, resolveRole: ResolveRole = .default) -> UInt32?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of UInt64 type.
Declaration
Swift
public func getProperty(_ path: String, type: UInt64.Type, resolveRole: ResolveRole = .default) -> UInt64?
Parameters
path
Property path.
type
Property type.
resolveRole
The resolve role.
Return Value
The property.
-
Get property of ConfigProperty type.
Declaration
Swift
public func getProperty<T>(_ path: String, type: T.Type, resolveRole: ResolveRole = .default) -> T? where T : ConfigProperty
Parameters
path
Property path.
type
Property type inherit ConfigProperty.
resolveRole
The resolve role.
Return Value
The property.