mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Update examples in README.md
This commit is contained in:
parent
4e8555c7da
commit
e46dfccd26
10
README.md
10
README.md
|
@ -23,7 +23,7 @@ See the Poodinis [DUB project page] for instructions on how to include Poodinis
|
||||||
###Quickstart
|
###Quickstart
|
||||||
The following example shows the typical usage of Poodinis:
|
The following example shows the typical usage of Poodinis:
|
||||||
```d
|
```d
|
||||||
import poodinis.container; // The only import needed for now
|
import poodinis.dependency;
|
||||||
|
|
||||||
interface Database{};
|
interface Database{};
|
||||||
class RelationalDatabase : Database {}
|
class RelationalDatabase : Database {}
|
||||||
|
@ -34,7 +34,7 @@ class DataWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
auto container = Container.getInstance();
|
auto container = DependencyContainer.getInstance();
|
||||||
container.register!DataWriter;
|
container.register!DataWriter;
|
||||||
container.register!(Database, RelationalDatabase);
|
container.register!(Database, RelationalDatabase);
|
||||||
|
|
||||||
|
@ -46,12 +46,12 @@ void main() {
|
||||||
To register a class, a new dependency container must be instantiated:
|
To register a class, a new dependency container must be instantiated:
|
||||||
```d
|
```d
|
||||||
// Register a private container
|
// Register a private container
|
||||||
auto container = new Container();
|
auto container = new DependencyContainer();
|
||||||
// Or use the singleton container
|
// Or use the singleton container
|
||||||
container = Container.getInstance();
|
container = DependencyContainer.getInstance();
|
||||||
```
|
```
|
||||||
###Registering dependencies
|
###Registering dependencies
|
||||||
They make dependencies available, they have to be registered:
|
To make dependencies available, they have to be registered:
|
||||||
```d
|
```d
|
||||||
// Register concrete class
|
// Register concrete class
|
||||||
container.register!ExampleClass;
|
container.register!ExampleClass;
|
||||||
|
|
Loading…
Reference in a new issue