mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add quickstart example from README as compilable sub-config
This commit is contained in:
parent
18a33ac8b9
commit
a41bfe8ac4
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
||||||
poodinis.exe
|
/poodinis.exe
|
||||||
poodinis.lib
|
/poodinis.lib
|
||||||
poodinis.obj
|
/poodinis.obj
|
||||||
|
/quickstartExample.exe
|
||||||
/.settings
|
/.settings
|
||||||
/.dub
|
/.dub
|
||||||
/dub.selections.json
|
/dub.selections.json
|
||||||
|
|
|
@ -2,3 +2,4 @@ language: d
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- dub test --build=unittest --config=unittest
|
- dub test --build=unittest --config=unittest
|
||||||
|
- dub build --build=release --config=quickstartExample
|
||||||
|
|
13
dub.json
13
dub.json
|
@ -30,6 +30,19 @@
|
||||||
"dflags-dmd": [
|
"dflags-dmd": [
|
||||||
"-main"
|
"-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
17
example/quickstart/app.d
Normal 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;
|
||||||
|
}
|
Loading…
Reference in a new issue