2015-12-28 22:45:15 +01:00
|
|
|
/**
|
|
|
|
* Poodinis Dependency Injection Framework
|
|
|
|
* Copyright 2014-2015 Mike Bierlee
|
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* The full terms of the license can be found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2015-07-01 21:05:00 +02:00
|
|
|
import poodinis;
|
2015-03-22 14:55:29 +01:00
|
|
|
|
|
|
|
interface Database{};
|
|
|
|
class RelationalDatabase : Database {}
|
|
|
|
|
|
|
|
class DataWriter {
|
|
|
|
@Autowire
|
|
|
|
public Database database; // Automatically injected when class is resolved
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
auto dependencies = DependencyContainer.getInstance();
|
|
|
|
dependencies.register!DataWriter;
|
|
|
|
dependencies.register!(Database, RelationalDatabase);
|
|
|
|
|
|
|
|
auto writer = dependencies.resolve!DataWriter;
|
|
|
|
}
|