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
|
```d
|
||||||
class BluePaint {
|
class BluePaint {
|
||||||
@Autowire!Blue
|
@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.
|
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 {
|
class ColorMixer {
|
||||||
@Autowire
|
@Autowire
|
||||||
public Color[] colors;
|
private Color[] colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies.register!(Color, Blue);
|
dependencies.register!(Color, Blue);
|
||||||
|
@ -171,10 +171,10 @@ This means that after the registration of an application context some dependenci
|
||||||
class Context : ApplicationContext {
|
class Context : ApplicationContext {
|
||||||
|
|
||||||
@Autowire
|
@Autowire
|
||||||
public SomeClass someClass;
|
private SomeClass someClass;
|
||||||
|
|
||||||
@Autowire
|
@Autowire
|
||||||
public SomeOtherClass someOtherClass;
|
private SomeOtherClass someOtherClass;
|
||||||
|
|
||||||
public override void registerDependencies(shared(DependencyContainer) container) {
|
public override void registerDependencies(shared(DependencyContainer) container) {
|
||||||
container.register!SomeClass;
|
container.register!SomeClass;
|
||||||
|
|
|
@ -27,11 +27,11 @@ class SuperSecurityDevice {
|
||||||
|
|
||||||
class SecurityManager {
|
class SecurityManager {
|
||||||
@Autowire
|
@Autowire
|
||||||
public SuperSecurityDevice levelOneSecurity;
|
private SuperSecurityDevice levelOneSecurity;
|
||||||
|
|
||||||
@Autowire
|
@Autowire
|
||||||
@AssignNewInstance
|
@AssignNewInstance
|
||||||
public SuperSecurityDevice levelTwoSecurity;
|
private SuperSecurityDevice levelTwoSecurity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import std.stdio;
|
||||||
class TownSquare {
|
class TownSquare {
|
||||||
|
|
||||||
@Autowire
|
@Autowire
|
||||||
public MarketStall marketStall;
|
private MarketStall marketStall;
|
||||||
|
|
||||||
public void makeSound() {
|
public void makeSound() {
|
||||||
marketStall.announceGoodsForSale();
|
marketStall.announceGoodsForSale();
|
||||||
|
@ -45,7 +45,7 @@ class MarketStall {
|
||||||
class ExampleApplicationContext : ApplicationContext {
|
class ExampleApplicationContext : ApplicationContext {
|
||||||
|
|
||||||
@Autowire
|
@Autowire
|
||||||
public Goods goods;
|
private Goods goods;
|
||||||
|
|
||||||
public override void registerDependencies(shared(DependencyContainer) container) {
|
public override void registerDependencies(shared(DependencyContainer) container) {
|
||||||
container.register!(Goods, Fish);
|
container.register!(Goods, Fish);
|
||||||
|
|
|
@ -33,7 +33,7 @@ class CardboardBoxPie : Pie {
|
||||||
|
|
||||||
class PieEater {
|
class PieEater {
|
||||||
@Autowire
|
@Autowire
|
||||||
public Pie[] pies;
|
private Pie[] pies;
|
||||||
|
|
||||||
public void eatThemAll() {
|
public void eatThemAll() {
|
||||||
foreach(pie ; pies) {
|
foreach(pie ; pies) {
|
||||||
|
|
|
@ -29,10 +29,10 @@ class HybridCar {
|
||||||
alias KilometersPerHour = int;
|
alias KilometersPerHour = int;
|
||||||
|
|
||||||
@Autowire!FuelEngine
|
@Autowire!FuelEngine
|
||||||
public Engine fuelEngine;
|
private Engine fuelEngine;
|
||||||
|
|
||||||
@Autowire!ElectricEngine
|
@Autowire!ElectricEngine
|
||||||
public Engine electricEngine;
|
private Engine electricEngine;
|
||||||
|
|
||||||
public void moveAtSpeed(KilometersPerHour speed) {
|
public void moveAtSpeed(KilometersPerHour speed) {
|
||||||
if (speed <= 45) {
|
if (speed <= 45) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ class RelationalDatabase : Database {}
|
||||||
|
|
||||||
class DataWriter {
|
class DataWriter {
|
||||||
@Autowire
|
@Autowire
|
||||||
public Database database; // Automatically injected when class is resolved
|
private Database database; // Automatically injected when class is resolved
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
Loading…
Reference in a new issue