unify the mappings
This commit is contained in:
parent
31ccb1ecd2
commit
65c71d6ff8
@ -66,7 +66,15 @@ extension MoleculeViewProtocol {
|
||||
public extension ModelRegistry {
|
||||
/// Returns the type of molecule view for the given model
|
||||
static func getMoleculeClass(_ model: MoleculeModelProtocol) -> MoleculeViewProtocol.Type? {
|
||||
return ModelRegistry.getHandler(model) as? MoleculeViewProtocol.Type
|
||||
do {
|
||||
let type = try ModelRegistry.getHandler(model) as! MoleculeViewProtocol.Type
|
||||
return type
|
||||
} catch {
|
||||
if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: #function) {
|
||||
MVMCoreLoggingHandler.shared()?.addError(toLog: errorObject)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a molecule with the given model.
|
||||
|
||||
@ -21,9 +21,15 @@ public extension PageBehaviorHandlerProtocol {
|
||||
}
|
||||
var behaviors: [PageBehaviorProtocol] = []
|
||||
for behaviorModel in behaviorModels {
|
||||
guard let handlerType = ModelRegistry.getHandler(behaviorModel) as? PageBehaviorProtocol.Type else { continue }
|
||||
let behavior = handlerType.init(model: behaviorModel, delegateObject: delegateObject)
|
||||
behaviors.append(behavior)
|
||||
do {
|
||||
let handlerType = try ModelRegistry.getHandler(behaviorModel) as! PageBehaviorProtocol.Type
|
||||
let behavior = handlerType.init(model: behaviorModel, delegateObject: delegateObject)
|
||||
behaviors.append(behavior)
|
||||
} catch {
|
||||
if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: #function) {
|
||||
MVMCoreLoggingHandler.shared()?.addError(toLog: errorObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
self.behaviors = behaviors.count > 0 ? behaviors : nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user