Table of Contents

Dependency injection

The Screenplay design pattern is fundamentally compatible with and based upon dependency injection, aka DI. You may add Screenplay to an existing container if you wish, via the AddScreenplay extension method. Alternatively you may create an instance of Screenplay which uses its own self-contained DI container with the static Screenplay.Create helper method.

Scopes

Screenplay makes use of Dependency Injection Scopes. As you can see on the diagram of how Actors, Abilities and Performables relate to one another, each Screenplay contains and executes many Performances. Each performance is executed within its own DI scope, thus scoped services will have one shared instance per performance.

It is also important to note that within DI, the Screenplay object must be added as a singleton (the mechanisms described above all do this for you). As a consequence there may be at most one Screenplay object per dependency injection container.

Using DI in Screenplay

TODO: Write this section!