Table of Contents

Dependency injection scope

Developers familiar with dependency injection are likely to be familiar with the concept of DI Scopes. Screenplay uses this concept; a number of its services are added to the container with a per-scope lifetime. Screenplay creates a new DI scope per Performance. As you can see on the diagram of how Actors, Abilities and Performables relate to one another, each Screenplay contains and executes many performances. This scope-creation is handled automatically by the Screenplay framework logic.

Within a performance, when any of the scoped services (listed below) are injected, each point of injection will receive the same shared instance of that service. Instances are independent per-performance; each performance gets its own shared instance of each of the listed services.

List of scoped services

The following services are added to DI "per lifetime scope".

List of singleton services

The following services are added to DI as singletons. There is only ever a single instance of these services per Screenplay.