registerAsType method
void
registerAsType(
- dynamic locator,
- dynamic type
inherited
Registers a component using its type (a constructor function).
locator
a locator to identify component to be created.type
a component type.
Implementation
void registerAsType(locator, type) {
if (locator == null) throw Exception('Locator cannot be null');
if (type == null) throw Exception('Factory cannot be null');
_registrations.add(Registration(locator, (locator) {
try {
return TypeReflector.createInstanceByType(type, []);
} catch (ex) {
return null;
}
}));
}