From a41bfe8ac4e8229fbf8c5eb9e73786b1865e3eac Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sat, 21 Feb 2015 17:20:57 +0100 Subject: [PATCH] Add quickstart example from README as compilable sub-config --- .gitignore | 7 ++++--- .travis.yml | 1 + dub.json | 15 ++++++++++++++- example/quickstart/app.d | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 example/quickstart/app.d diff --git a/.gitignore b/.gitignore index 214723e..bd634af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -poodinis.exe -poodinis.lib -poodinis.obj +/poodinis.exe +/poodinis.lib +/poodinis.obj +/quickstartExample.exe /.settings /.dub /dub.selections.json diff --git a/.travis.yml b/.travis.yml index 71fd214..b300fa1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,4 @@ language: d script: - dub test --build=unittest --config=unittest + - dub build --build=release --config=quickstartExample diff --git a/dub.json b/dub.json index 394f774..35e5113 100644 --- a/dub.json +++ b/dub.json @@ -30,6 +30,19 @@ "dflags-dmd": [ "-main" ] + }, + { + "name" : "quickstartExample", + "description" : "Quickstart example from the Poodinis readme.", + "license": "MIT", + "targetType": "executable", + "targetName": "quickstartExample", + "sourcePaths": [ + "example/quickstart" + ], + "importPaths": [ + "source" + ] } ] -} \ No newline at end of file +} diff --git a/example/quickstart/app.d b/example/quickstart/app.d new file mode 100644 index 0000000..c8c6c09 --- /dev/null +++ b/example/quickstart/app.d @@ -0,0 +1,17 @@ +import poodinis.dependency; + +interface Database{}; +class RelationalDatabase : Database {} + +class DataWriter { + @Autowire + public Database database; // Automatically injected when class is resolved +} + +void main() { + auto container = DependencyContainer.getInstance(); + container.register!DataWriter; + container.register!(Database, RelationalDatabase); + + auto writer = container.resolve!DataWriter; +}