mirror of
https://github.com/mbierlee/mirage-injector.git
synced 2024-11-15 05:14:01 +01:00
Add function to register value injectors
This commit is contained in:
parent
401a60cab3
commit
d953b6af72
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"dfmt.braceStyle": "allman"
|
||||||
|
}
|
27
.vscode/tasks.json
vendored
Normal file
27
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Dub Build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "dub build",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Dub Test",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "dub test",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": {
|
||||||
|
"kind": "test",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -6,3 +6,65 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module poodinis.valueinjector.mirage;
|
module poodinis.valueinjector.mirage;
|
||||||
|
|
||||||
|
import poodinis : ValueInjector, DependencyContainer;
|
||||||
|
|
||||||
|
class MirageValueInjector(Type) : ValueInjector!Type
|
||||||
|
{
|
||||||
|
public override Type get(string key)
|
||||||
|
{
|
||||||
|
throw new Exception("Not yet implemented");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alias MirageBoolValueInjector = MirageValueInjector!bool;
|
||||||
|
alias MirageByteValueInjector = MirageValueInjector!byte;
|
||||||
|
alias MirageUbyteValueInjector = MirageValueInjector!ubyte;
|
||||||
|
alias MirageCharValueInjector = MirageValueInjector!char;
|
||||||
|
alias MirageShortValueInjector = MirageValueInjector!short;
|
||||||
|
alias MirageUshortValueInjector = MirageValueInjector!ushort;
|
||||||
|
alias MirageWcharValueInjector = MirageValueInjector!wchar;
|
||||||
|
alias MirageIntValueInjector = MirageValueInjector!int;
|
||||||
|
alias MirageUintValueInjector = MirageValueInjector!uint;
|
||||||
|
alias MirageDcharValueInjector = MirageValueInjector!dchar;
|
||||||
|
alias MirageLongValueInjector = MirageValueInjector!long;
|
||||||
|
alias MirageUlongValueInjector = MirageValueInjector!ulong;
|
||||||
|
alias MirageFloatValueInjector = MirageValueInjector!float;
|
||||||
|
alias MirageDoubleValueInjector = MirageValueInjector!double;
|
||||||
|
alias MirageRealValueInjector = MirageValueInjector!real;
|
||||||
|
alias MirageStringValueInjector = MirageValueInjector!string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers Mirage Config value injectors for all primitive types.
|
||||||
|
* Params:
|
||||||
|
* container = Dependency container to register injectors with.
|
||||||
|
*/
|
||||||
|
public void registerMirageInjectors(shared(DependencyContainer) container)
|
||||||
|
{
|
||||||
|
container.register!(ValueInjector!bool, MirageBoolValueInjector);
|
||||||
|
container.register!(ValueInjector!byte, MirageByteValueInjector);
|
||||||
|
container.register!(ValueInjector!ubyte, MirageUbyteValueInjector);
|
||||||
|
container.register!(ValueInjector!char, MirageCharValueInjector);
|
||||||
|
container.register!(ValueInjector!short, MirageShortValueInjector);
|
||||||
|
container.register!(ValueInjector!ushort, MirageUshortValueInjector);
|
||||||
|
container.register!(ValueInjector!wchar, MirageWcharValueInjector);
|
||||||
|
container.register!(ValueInjector!int, MirageIntValueInjector);
|
||||||
|
container.register!(ValueInjector!uint, MirageUintValueInjector);
|
||||||
|
container.register!(ValueInjector!dchar, MirageDcharValueInjector);
|
||||||
|
container.register!(ValueInjector!long, MirageLongValueInjector);
|
||||||
|
container.register!(ValueInjector!ulong, MirageUlongValueInjector);
|
||||||
|
container.register!(ValueInjector!float, MirageFloatValueInjector);
|
||||||
|
container.register!(ValueInjector!double, MirageDoubleValueInjector);
|
||||||
|
container.register!(ValueInjector!real, MirageRealValueInjector);
|
||||||
|
container.register!(ValueInjector!string, MirageStringValueInjector);
|
||||||
|
}
|
||||||
|
|
||||||
|
version (unittest)
|
||||||
|
{
|
||||||
|
@("Register primitive value injectors")
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
auto dependencies = new shared DependencyContainer;
|
||||||
|
dependencies.registerMirageInjectors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue