Open CrazyFlasher opened 5 years ago
It returns true
if a type is mapped to something... meaning that injector.getInstance(<Type>)
will return a value and not throw an exception.
It doesn't really matter if it is value or type mapping because injector can only have one mapping per type anyway (unless it's named but that's not the point here)
Think of it this way - optional injection is pretty much if(injector.hasMapping(field.type)) field.value = injector.getInstance(field.type);
where field is the one that is being injected into.
Does it make sense?
Not exactly. Here is simple example
var injector:IDependencyInjector = new Injector();
injector.mapToType(IMockPool_1, MockPool_1);
Assert.isTrue(injector.hasMapping(IMockPool_1));
injector.mapToValue(IMockPool_1, injector.getInstance(IMockPool_1));
// not implemented?
// Assert.isTrue(injector.hasMappingToValue(IMockPool_1));
injector.mapClassNameToType("mock.obj.IMockObj_2", MockObj_2);
// not implemented?
// Assert.isTrue(injector.hasClassNameMapping("mock.obj.IMockObj_2"));
var arr:Array<Int> = [1, 2, 3];
injector.mapClassNameToValue("Array<Int>", arr);
// not implemented?
// Assert.isTrue(injector.hasClassNameMappingToValue("Array<Int>"));
How can I get
hasClassToValueMapping
,hasClassNameToValueMapping
,hasClassToTypeMapping
,hasClassNameToTypeMapping
?I see only 1 method
hasMapping
. What actually it returns? type to class?