-
Notifications
You must be signed in to change notification settings - Fork 16
/
AutoDependencyInjection.generated.swift
126 lines (102 loc) · 5.13 KB
/
AutoDependencyInjection.generated.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Generated using Sourcery 2.0.3 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable all
import CioInternalCommon
import Foundation
/**
######################################################
Documentation
######################################################
This automatically generated file you are viewing is a dependency injection graph for your app's source code.
You may be wondering a couple of questions.
1. How did this file get generated? Answer --> https://github.com/levibostian/Sourcery-DI#how
2. Why use this dependency injection graph instead of X other solution/tool? Answer --> https://github.com/levibostian/Sourcery-DI#why-use-this-project
3. How do I add dependencies to this graph file? Follow one of the instructions below:
* Add a non singleton class: https://github.com/levibostian/Sourcery-DI#add-a-non-singleton-class
* Add a generic class: https://github.com/levibostian/Sourcery-DI#add-a-generic-class
* Add a singleton class: https://github.com/levibostian/Sourcery-DI#add-a-singleton-class
* Add a class from a 3rd party library/SDK: https://github.com/levibostian/Sourcery-DI#add-a-class-from-a-3rd-party
* Add a `typealias` https://github.com/levibostian/Sourcery-DI#add-a-typealias
4. How do I get dependencies from the graph in my code?
```
// If you have a class like this:
class OffRoadWheels {}
class ViewController: UIViewController {
// Call the property getter to get your dependency from the graph:
let wheels = DIGraph.getInstance(siteId: "").offRoadWheels
// note the name of the property is name of the class with the first letter lowercase.
}
```
5. How do I use this graph in my test suite?
```
let mockOffRoadWheels = // make a mock of OffRoadWheels class
DIGraph().override(mockOffRoadWheels, OffRoadWheels.self)
```
Then, when your test function finishes, reset the graph:
```
DIGraph().reset()
```
*/
extension DIGraph {
// call in automated test suite to confirm that all dependnecies able to resolve and not cause runtime exceptions.
// internal scope so each module can provide their own version of the function with the same name.
@available(iOSApplicationExtension, unavailable) // some properties could be unavailable to app extensions so this function must also.
func testDependenciesAbleToResolve() -> Int {
var countDependenciesResolved = 0
_ = deviceAttributesProvider
countDependenciesResolved += 1
return countDependenciesResolved
}
// DeviceAttributesProvider
var deviceAttributesProvider: DeviceAttributesProvider {
getOverriddenInstance() ??
newDeviceAttributesProvider
}
private var newDeviceAttributesProvider: DeviceAttributesProvider {
SdkDeviceAttributesProvider(deviceInfo: deviceInfo)
}
}
extension DIGraphShared {
// call in automated test suite to confirm that all dependnecies able to resolve and not cause runtime exceptions.
// internal scope so each module can provide their own version of the function with the same name.
@available(iOSApplicationExtension, unavailable) // some properties could be unavailable to app extensions so this function must also.
func testDependenciesAbleToResolve() -> Int {
var countDependenciesResolved = 0
_ = autoTrackingScreenViewStore
countDependenciesResolved += 1
_ = deviceAttributesProvider
countDependenciesResolved += 1
return countDependenciesResolved
}
// Handle classes annotated with InjectRegisterShared
// AutoTrackingScreenViewStore (singleton)
var autoTrackingScreenViewStore: AutoTrackingScreenViewStore {
getOverriddenInstance() ??
sharedAutoTrackingScreenViewStore
}
var sharedAutoTrackingScreenViewStore: AutoTrackingScreenViewStore {
// Use a DispatchQueue to make singleton thread safe. You must create unique dispatchqueues instead of using 1 shared one or you will get a crash when trying
// to call DispatchQueue.sync{} while already inside another DispatchQueue.sync{} call.
DispatchQueue(label: "DIGraphShared_AutoTrackingScreenViewStore_singleton_access").sync {
if let overridenDep: AutoTrackingScreenViewStore = getOverriddenInstance() {
return overridenDep
}
let existingSingletonInstance = self.singletons[String(describing: AutoTrackingScreenViewStore.self)] as? AutoTrackingScreenViewStore
let instance = existingSingletonInstance ?? _get_autoTrackingScreenViewStore()
self.singletons[String(describing: AutoTrackingScreenViewStore.self)] = instance
return instance
}
}
private func _get_autoTrackingScreenViewStore() -> AutoTrackingScreenViewStore {
InMemoryAutoTrackingScreenViewStore(lockManager: lockManager)
}
// DeviceAttributesProvider
var deviceAttributesProvider: DeviceAttributesProvider {
getOverriddenInstance() ??
newDeviceAttributesProvider
}
private var newDeviceAttributesProvider: DeviceAttributesProvider {
SdkDeviceAttributesProvider(deviceInfo: deviceInfo)
}
}
// swiftlint:enable all