import Foundation public final class DIContainer { public static let shared = DIContainer() public private(set) var values = InjectionValues() private init() {} public func register( _ keyPath: WritableKeyPath, value: T ) { values[keyPath: keyPath] = value } public func resolve( _ keyPath: KeyPath ) -> T { guard let value = values[keyPath: keyPath] else { fatalError( "DIContainer: No value registered for \(keyPath). " + "Call DIContainer.shared.register(\\.key, value:) during app startup." ) } return value } public func reset() { values = InjectionValues() } }