ConfigurationLoader
open class ConfigurationLoader
A ConfigurationLoader acts as a container of configuration providers (objects that conform to the ConfigurationProviding protocol), and provides an interface to access them. This class acts as a mediator between configuration providers and the application, providing callback mechanisms through a ConfigurationLoaderDelegate. In addition, an alternate method to save data may be supplied by an object that implements the ConfigurationPersisting protocol.
-
The queue of configuration providers held by this object. Corresponds to the
providersspecified during initialization, however, ifnilwas specified, the default queue will be constructed.Declaration
Swift
public var providers: [ConfigurationProviding] { get set } -
Delegate used to communicate between the loader instance and the application.
Declaration
Swift
public weak var delegate: ConfigurationLoaderDelegate? -
Optionally supplied property that uses a
ConfigurationPersistingobject’s implementation ofpersistConfiguration(_:)to pass configuration data to. Ifnil, configuration data will be written toUserDefaultsunderConfigurationProviderUserDefaultsKey(com.sap.configuration.provider.configurationstore).Declaration
Swift
public var outputHandler: ConfigurationPersisting? { get set }
-
Creates a
ConfigurationLoaderwith the specified parameters.Declaration
Swift
public init(delegate: ConfigurationLoaderDelegate? = nil, providers: [ConfigurationProviding]? = nil, outputHandler: ConfigurationPersisting? = nil)Parameters
providersAn array of configuration providers to process. Objects in this array must conform to the
ConfigurationProvidingprotocol. Anilvalue creates the default queue.outputHandlerProvides ability to use an alternate storage mechanism for configuration provider data. Must conform to the
ConfigurationPersistingprotocol. Ifnilis supplied, any found configuration data will be written toUserDefaultsunderConfigurationProviderUserDefaultsKey(com.sap.configuration.provider.configurationstore).
-
Calls
self.outputHandler‘sConfigurationPersisting.resetPersistedConfiguration(). Ifnilwas specified for theoutputHandlerduring initialization, written data will be cleared fromConfigurationProviderUserDefaultsKey.Declaration
Swift
open func resetStoredData() -
Attempts to obtain configuration data from all entries in the queue (the collection of configuration providers in
self.providers) until data is found or the queue has been exhausted.Declaration
Swift
@discardableResult open func loadConfiguration(userInputs: [String : [String : Any]] = [:]) -> BoolParameters
userInputsUser inputs collected for subsequent call to a configuration provider object’s
ConfigurationProviding.provideConfiguration(input:)method.Return Value
trueif configuration data was found from one of the providers in the queue; otherwise,false. -
config providers using default heuristic
Declaration
Swift
@discardableResult open func constructDefaultConfigurationProviderQueue() -> Int