@@ -23,12 +23,11 @@ open class DependencyInjector {
2323 * @return True on success, otherwise false
2424 */
2525 @discardableResult
26- open func register( module: DependencyModule ) -> Bool {
26+ open func register( module: DependencyModule ) -> Self {
2727 if self . modules. index ( of: module) == nil {
2828 self . modules. insert ( module, at: 0 )
29- return true
3029 }
31- return false
30+ return self
3231 }
3332
3433 /**
@@ -51,28 +50,6 @@ open class DependencyInjector {
5150 return self . inject ( type: type, scope: nil , arguments: nil )
5251 }
5352
54- /**
55- * Creates a new instance conforming the input Type
56- * The injector search the first module that can provide the injection (The default scope is used)
57- * @param type The given Type you want to inject
58- * @param arguments Used by the provider (Such as nonnull parameters for initializers)
59- * @return An injected object, nil if an error occurred
60- */
61- open func inject< T> ( type: T . Type , arguments: [ String : Any ] ? ) -> T ? {
62- return self . inject ( type: type, scope: nil , arguments: arguments)
63- }
64-
65- /**
66- * Creates a new instance conforming the input Type
67- * The injector search the first module that can provide the injection
68- * @param type The given Type you want to inject
69- * @param scope Custom scope, give nil to use default scope
70- * @return An injected object, nil if an error occurred
71- */
72- open func inject< T> ( type: T . Type , scope: String ? ) -> T ? {
73- return self . inject ( type: type, scope: scope, arguments: nil )
74- }
75-
7653 /**
7754 * Creates a new instance conforming the input Type
7855 * The injector search the first module that can provide the injection
@@ -81,7 +58,7 @@ open class DependencyInjector {
8158 * @param arguments Used by the provider (Such as nonnull parameters for initializers)
8259 * @return An injected object, nil if an error occurred
8360 */
84- open func inject< T> ( type: T . Type , scope: String ? , arguments: [ String : Any ] ? ) -> T ? {
61+ open func inject< T> ( type: T . Type , scope: String ? = nil , arguments: [ String : Any ] ? = nil ) -> T ? {
8562 for module in self . modules {
8663 if let provider = module. provider ( type: type, scope: scope) {
8764 return provider ( self , arguments)
0 commit comments