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; +}