diff --git a/README.md b/README.md index 52c2829..a7f5c40 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,17 @@ The following example shows the typical usage of Poodinis: ```d import poodinis; +class Driver {} + interface Database{}; -class RelationalDatabase : Database {} + +class RelationalDatabase : Database { + private Driver driver; + + this(Driver driver) { // Automatically injected on creation by container + this.driver = driver; + } +} class DataWriter { @Autowire @@ -43,6 +52,7 @@ class DataWriter { void main() { auto dependencies = new shared DependencyContainer(); + dependencies.register!Driver; dependencies.register!DataWriter; dependencies.register!(Database, RelationalDatabase); diff --git a/example/quickstart/app.d b/example/quickstart/app.d index 02d3823..b5d21ab 100644 --- a/example/quickstart/app.d +++ b/example/quickstart/app.d @@ -7,8 +7,17 @@ import poodinis; +class Driver {} + interface Database{}; -class RelationalDatabase : Database {} + +class RelationalDatabase : Database { + private Driver driver; + + this(Driver driver) { // Automatically injected on creation by container + this.driver = driver; + } +} class DataWriter { @Autowire @@ -17,6 +26,7 @@ class DataWriter { void main() { auto dependencies = new shared DependencyContainer(); + dependencies.register!Driver; dependencies.register!DataWriter; dependencies.register!(Database, RelationalDatabase);