Add quickstart example from README as compilable sub-config

This commit is contained in:
Mike Bierlee 2015-02-21 17:20:57 +01:00
parent 18a33ac8b9
commit a41bfe8ac4
4 changed files with 36 additions and 4 deletions

7
.gitignore vendored
View file

@ -1,6 +1,7 @@
poodinis.exe
poodinis.lib
poodinis.obj
/poodinis.exe
/poodinis.lib
/poodinis.obj
/quickstartExample.exe
/.settings
/.dub
/dub.selections.json

View file

@ -2,3 +2,4 @@ language: d
script:
- dub test --build=unittest --config=unittest
- dub build --build=release --config=quickstartExample

View file

@ -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"
]
}
]
}

17
example/quickstart/app.d Normal file
View file

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