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
providers
specified during initialization, however, ifnil
was 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
ConfigurationPersisting
object’s implementation ofpersistConfiguration(_:)
to pass configuration data to. Ifnil
, configuration data will be written toUserDefaults
underConfigurationProviderUserDefaultsKey
(com.sap.configuration.provider.configurationstore
).Declaration
Swift
public var outputHandler: ConfigurationPersisting? { get set }
-
Creates a
ConfigurationLoader
with the specified parameters.Declaration
Swift
public init(delegate: ConfigurationLoaderDelegate? = nil, providers: [ConfigurationProviding]? = nil, outputHandler: ConfigurationPersisting? = nil)
Parameters
providers
An array of configuration providers to process. Objects in this array must conform to the
ConfigurationProviding
protocol. Anil
value creates the default queue.outputHandler
Provides ability to use an alternate storage mechanism for configuration provider data. Must conform to the
ConfigurationPersisting
protocol. Ifnil
is supplied, any found configuration data will be written toUserDefaults
underConfigurationProviderUserDefaultsKey
(com.sap.configuration.provider.configurationstore
).
-
Calls
self.outputHandler
‘sConfigurationPersisting.resetPersistedConfiguration()
. Ifnil
was specified for theoutputHandler
during 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]] = [:]) -> Bool
Parameters
userInputs
User inputs collected for subsequent call to a configuration provider object’s
ConfigurationProviding.provideConfiguration(input:)
method.Return Value
true
if 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