You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
1.2 KiB

2 years ago
  1. //
  2. // Copyright © 2019 Swinject Contributors. All rights reserved.
  3. //
  4. extension ObjectScope {
  5. /// A new instance is always created by the `Container` when a type is resolved.
  6. /// The instance is not shared.
  7. public static let transient = ObjectScope(storageFactory: TransientStorage.init, description: "transient")
  8. /// Instances are shared only when an object graph is being created,
  9. /// otherwise a new instance is created by the `Container`. This is the default scope.
  10. public static let graph = ObjectScope(storageFactory: GraphStorage.init, description: "graph")
  11. /// An instance provided by the `Container` is shared within the `Container` and its child `Containers`.
  12. public static let container = ObjectScope(storageFactory: PermanentStorage.init, description: "container")
  13. /// An instance provided by the `Container` is shared within the `Container` and its child `Container`s
  14. /// as long as there are strong references to given instance. Otherwise new instance is created
  15. /// when resolving the type.
  16. public static let weak = ObjectScope(storageFactory: WeakStorage.init, description: "weak",
  17. parent: ObjectScope.graph)
  18. }