|
14 | 14 |
|
15 | 15 | import Foundation |
16 | 16 |
|
17 | | -// MARK: - Registration with Arguments |
18 | | - |
19 | | -extension SwinjectContainer { |
20 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
21 | | - /// |
22 | | - /// - Parameters: |
23 | | - /// - serviceType: The service type to register. |
24 | | - /// - name: A registration name, which is used to differentiate from other registrations |
25 | | - /// that have the same service and factory types. |
26 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
27 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
28 | | - /// It takes a `SwinjectResolver` instance and 1 argument to inject dependencies to the instance, |
29 | | - /// and returns the instance of the component type for the service. |
30 | | - /// |
31 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
32 | | - @discardableResult |
33 | | - public func register<Service, Arg1>( |
34 | | - _ serviceType: Service.Type, |
35 | | - name: String? = nil, |
36 | | - factory: @escaping (SwinjectResolver, Arg1) -> Service |
37 | | - ) -> ServiceEntry<Service> { |
38 | | - return _register(serviceType, factory: factory, name: name) |
39 | | - } |
40 | | - |
41 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
42 | | - /// |
43 | | - /// - Parameters: |
44 | | - /// - serviceType: The service type to register. |
45 | | - /// - name: A registration name, which is used to differentiate from other registrations |
46 | | - /// that have the same service and factory types. |
47 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
48 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
49 | | - /// It takes a `SwinjectResolver` instance and 2 arguments to inject dependencies to the instance, |
50 | | - /// and returns the instance of the component type for the service. |
51 | | - /// |
52 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
53 | | - @discardableResult |
54 | | - public func register<Service, Arg1, Arg2>( |
55 | | - _ serviceType: Service.Type, |
56 | | - name: String? = nil, |
57 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2) -> Service |
58 | | - ) -> ServiceEntry<Service> { |
59 | | - return _register(serviceType, factory: factory, name: name) |
60 | | - } |
61 | | - |
62 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
63 | | - /// |
64 | | - /// - Parameters: |
65 | | - /// - serviceType: The service type to register. |
66 | | - /// - name: A registration name, which is used to differentiate from other registrations |
67 | | - /// that have the same service and factory types. |
68 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
69 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
70 | | - /// It takes a `SwinjectResolver` instance and 3 arguments to inject dependencies to the instance, |
71 | | - /// and returns the instance of the component type for the service. |
72 | | - /// |
73 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
74 | | - @discardableResult |
75 | | - public func register<Service, Arg1, Arg2, Arg3>( |
76 | | - _ serviceType: Service.Type, |
77 | | - name: String? = nil, |
78 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2, Arg3) -> Service |
79 | | - ) -> ServiceEntry<Service> { |
80 | | - return _register(serviceType, factory: factory, name: name) |
81 | | - } |
82 | | - |
83 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
84 | | - /// |
85 | | - /// - Parameters: |
86 | | - /// - serviceType: The service type to register. |
87 | | - /// - name: A registration name, which is used to differentiate from other registrations |
88 | | - /// that have the same service and factory types. |
89 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
90 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
91 | | - /// It takes a `SwinjectResolver` instance and 4 arguments to inject dependencies to the instance, |
92 | | - /// and returns the instance of the component type for the service. |
93 | | - /// |
94 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
95 | | - @discardableResult |
96 | | - public func register<Service, Arg1, Arg2, Arg3, Arg4>( |
97 | | - _ serviceType: Service.Type, |
98 | | - name: String? = nil, |
99 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2, Arg3, Arg4) -> Service |
100 | | - ) -> ServiceEntry<Service> { |
101 | | - return _register(serviceType, factory: factory, name: name) |
102 | | - } |
103 | | - |
104 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
105 | | - /// |
106 | | - /// - Parameters: |
107 | | - /// - serviceType: The service type to register. |
108 | | - /// - name: A registration name, which is used to differentiate from other registrations |
109 | | - /// that have the same service and factory types. |
110 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
111 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
112 | | - /// It takes a `SwinjectResolver` instance and 5 arguments to inject dependencies to the instance, |
113 | | - /// and returns the instance of the component type for the service. |
114 | | - /// |
115 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
116 | | - @discardableResult |
117 | | - public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5>( |
118 | | - _ serviceType: Service.Type, |
119 | | - name: String? = nil, |
120 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2, Arg3, Arg4, Arg5) -> Service |
121 | | - ) -> ServiceEntry<Service> { |
122 | | - return _register(serviceType, factory: factory, name: name) |
123 | | - } |
124 | | - |
125 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
126 | | - /// |
127 | | - /// - Parameters: |
128 | | - /// - serviceType: The service type to register. |
129 | | - /// - name: A registration name, which is used to differentiate from other registrations |
130 | | - /// that have the same service and factory types. |
131 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
132 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
133 | | - /// It takes a `SwinjectResolver` instance and 6 arguments to inject dependencies to the instance, |
134 | | - /// and returns the instance of the component type for the service. |
135 | | - /// |
136 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
137 | | - @discardableResult |
138 | | - public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>( |
139 | | - _ serviceType: Service.Type, |
140 | | - name: String? = nil, |
141 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) -> Service |
142 | | - ) -> ServiceEntry<Service> { |
143 | | - return _register(serviceType, factory: factory, name: name) |
144 | | - } |
145 | | - |
146 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
147 | | - /// |
148 | | - /// - Parameters: |
149 | | - /// - serviceType: The service type to register. |
150 | | - /// - name: A registration name, which is used to differentiate from other registrations |
151 | | - /// that have the same service and factory types. |
152 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
153 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
154 | | - /// It takes a `SwinjectResolver` instance and 7 arguments to inject dependencies to the instance, |
155 | | - /// and returns the instance of the component type for the service. |
156 | | - /// |
157 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
158 | | - @discardableResult |
159 | | - public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>( |
160 | | - _ serviceType: Service.Type, |
161 | | - name: String? = nil, |
162 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) -> Service |
163 | | - ) -> ServiceEntry<Service> { |
164 | | - return _register(serviceType, factory: factory, name: name) |
165 | | - } |
166 | | - |
167 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
168 | | - /// |
169 | | - /// - Parameters: |
170 | | - /// - serviceType: The service type to register. |
171 | | - /// - name: A registration name, which is used to differentiate from other registrations |
172 | | - /// that have the same service and factory types. |
173 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
174 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
175 | | - /// It takes a `SwinjectResolver` instance and 8 arguments to inject dependencies to the instance, |
176 | | - /// and returns the instance of the component type for the service. |
177 | | - /// |
178 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
179 | | - @discardableResult |
180 | | - public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>( |
181 | | - _ serviceType: Service.Type, |
182 | | - name: String? = nil, |
183 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) -> Service |
184 | | - ) -> ServiceEntry<Service> { |
185 | | - return _register(serviceType, factory: factory, name: name) |
186 | | - } |
187 | | - |
188 | | - /// Adds a registration for the specified service with the factory closure to specify how the service is resolved with dependencies. |
189 | | - /// |
190 | | - /// - Parameters: |
191 | | - /// - serviceType: The service type to register. |
192 | | - /// - name: A registration name, which is used to differentiate from other registrations |
193 | | - /// that have the same service and factory types. |
194 | | - /// - factory: The closure to specify how the service type is resolved with the dependencies of the type. |
195 | | - /// It is invoked when the `Container` needs to instantiate the instance. |
196 | | - /// It takes a `SwinjectResolver` instance and 9 arguments to inject dependencies to the instance, |
197 | | - /// and returns the instance of the component type for the service. |
198 | | - /// |
199 | | - /// - Returns: A registered `ServiceEntry` to configure more settings with method chaining. |
200 | | - @discardableResult |
201 | | - public func register<Service, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>( |
202 | | - _ serviceType: Service.Type, |
203 | | - name: String? = nil, |
204 | | - factory: @escaping (SwinjectResolver, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) -> Service |
205 | | - ) -> ServiceEntry<Service> { |
206 | | - return _register(serviceType, factory: factory, name: name) |
207 | | - } |
208 | | - |
209 | | -} |
210 | | - |
211 | 17 | // MARK: - SwinjectResolver with Arguments |
212 | 18 |
|
213 | 19 | extension SwinjectContainer { |
|
0 commit comments