mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Make all autowired members in examples and the tutorial private
To set a proper example!
This commit is contained in:
parent
965dcfb0a2
commit
fdbd3c06a1
|
@ -111,7 +111,7 @@ If you want to autowire a type registered to multiple concrete types, specify a
|
|||
```d
|
||||
class BluePaint {
|
||||
@Autowire!Blue
|
||||
public Color color;
|
||||
private Color color;
|
||||
}
|
||||
```
|
||||
If you registered multiple concrete types to the same supertype and you do not resolve using a qualifier, a ResolveException is thrown stating that there are multiple candidates for the type to be resolved.
|
||||
|
@ -124,7 +124,7 @@ If you have registered multiple concrete types to a super type, you can autowire
|
|||
|
||||
class ColorMixer {
|
||||
@Autowire
|
||||
public Color[] colors;
|
||||
private Color[] colors;
|
||||
}
|
||||
|
||||
dependencies.register!(Color, Blue);
|
||||
|
@ -171,10 +171,10 @@ This means that after the registration of an application context some dependenci
|
|||
class Context : ApplicationContext {
|
||||
|
||||
@Autowire
|
||||
public SomeClass someClass;
|
||||
private SomeClass someClass;
|
||||
|
||||
@Autowire
|
||||
public SomeOtherClass someOtherClass;
|
||||
private SomeOtherClass someOtherClass;
|
||||
|
||||
public override void registerDependencies(shared(DependencyContainer) container) {
|
||||
container.register!SomeClass;
|
||||
|
|
|
@ -27,11 +27,11 @@ class SuperSecurityDevice {
|
|||
|
||||
class SecurityManager {
|
||||
@Autowire
|
||||
public SuperSecurityDevice levelOneSecurity;
|
||||
private SuperSecurityDevice levelOneSecurity;
|
||||
|
||||
@Autowire
|
||||
@AssignNewInstance
|
||||
public SuperSecurityDevice levelTwoSecurity;
|
||||
private SuperSecurityDevice levelTwoSecurity;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
|
|
@ -12,7 +12,7 @@ import std.stdio;
|
|||
class TownSquare {
|
||||
|
||||
@Autowire
|
||||
public MarketStall marketStall;
|
||||
private MarketStall marketStall;
|
||||
|
||||
public void makeSound() {
|
||||
marketStall.announceGoodsForSale();
|
||||
|
@ -45,7 +45,7 @@ class MarketStall {
|
|||
class ExampleApplicationContext : ApplicationContext {
|
||||
|
||||
@Autowire
|
||||
public Goods goods;
|
||||
private Goods goods;
|
||||
|
||||
public override void registerDependencies(shared(DependencyContainer) container) {
|
||||
container.register!(Goods, Fish);
|
||||
|
|
|
@ -33,7 +33,7 @@ class CardboardBoxPie : Pie {
|
|||
|
||||
class PieEater {
|
||||
@Autowire
|
||||
public Pie[] pies;
|
||||
private Pie[] pies;
|
||||
|
||||
public void eatThemAll() {
|
||||
foreach(pie ; pies) {
|
||||
|
|
|
@ -29,10 +29,10 @@ class HybridCar {
|
|||
alias KilometersPerHour = int;
|
||||
|
||||
@Autowire!FuelEngine
|
||||
public Engine fuelEngine;
|
||||
private Engine fuelEngine;
|
||||
|
||||
@Autowire!ElectricEngine
|
||||
public Engine electricEngine;
|
||||
private Engine electricEngine;
|
||||
|
||||
public void moveAtSpeed(KilometersPerHour speed) {
|
||||
if (speed <= 45) {
|
||||
|
|
|
@ -12,7 +12,7 @@ class RelationalDatabase : Database {}
|
|||
|
||||
class DataWriter {
|
||||
@Autowire
|
||||
public Database database; // Automatically injected when class is resolved
|
||||
private Database database; // Automatically injected when class is resolved
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
|
Loading…
Reference in a new issue