Last active
February 18, 2018 07:45
-
-
Save mczachurski/12452abd9e5077b4b6062db1d0bd37f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DependencyContainer.swift | |
// TaskerServerPackageDescription | |
// | |
// Created by Marcin Czachurski on 12.02.2018. | |
// | |
import Foundation | |
import Dip | |
extension DependencyContainer { | |
public func configure(withConfiguration configuration: Configuration) { | |
self.registerConfiguration(container: self, configuration: configuration) | |
self.registerRepositories(container: self) | |
} | |
private func registerConfiguration(container: DependencyContainer, configuration: Configuration) { | |
container.register(.singleton) { configuration } | |
} | |
private func registerRepositories(container: DependencyContainer) { | |
container.register { TasksRepository(configuration: $0) as TasksRepositoryProtocol } | |
container.register { UsersRepository(configuration: $0) as UsersRepositoryProtocol } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment