update: updating 29 pass 5 fail
This commit is contained in:
parent
4f0f129900
commit
48c6ca8785
1 changed files with 6 additions and 14 deletions
|
@ -52,23 +52,13 @@ class Container implements ContainerContract, Map<String, dynamic> {
|
||||||
var className = parts[0];
|
var className = parts[0];
|
||||||
var methodName = parts.length > 1 ? parts[1] : null;
|
var methodName = parts.length > 1 ? parts[1] : null;
|
||||||
var instance = _make(className);
|
var instance = _make(className);
|
||||||
if (methodName == null) {
|
|
||||||
if (instance is Function) {
|
|
||||||
return Function.apply(instance, parameters);
|
|
||||||
} else if (instance is Type) {
|
|
||||||
return _make(instance.toString());
|
|
||||||
} else {
|
|
||||||
return 'run';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (instance is _DummyObject) {
|
if (instance is _DummyObject) {
|
||||||
throw BindingResolutionException('Class $className not found');
|
throw BindingResolutionException('Class $className not found');
|
||||||
}
|
}
|
||||||
if (instance is _DummyObject) {
|
if (methodName == null || methodName.isEmpty) {
|
||||||
return instance.noSuchMethod(
|
return _callMethod(instance, 'run', parameters);
|
||||||
Invocation.method(Symbol(methodName ?? 'run'), parameters));
|
|
||||||
}
|
}
|
||||||
return _callMethod(instance, methodName ?? 'run', parameters);
|
return _callMethod(instance, methodName, parameters);
|
||||||
} else if (callback.contains('::')) {
|
} else if (callback.contains('::')) {
|
||||||
var parts = callback.split('::');
|
var parts = callback.split('::');
|
||||||
var className = parts[0];
|
var className = parts[0];
|
||||||
|
@ -78,10 +68,12 @@ class Container implements ContainerContract, Map<String, dynamic> {
|
||||||
} else if (_methodBindings.containsKey(callback)) {
|
} else if (_methodBindings.containsKey(callback)) {
|
||||||
var boundMethod = _methodBindings[callback]!;
|
var boundMethod = _methodBindings[callback]!;
|
||||||
return Function.apply(boundMethod, [this, parameters]);
|
return Function.apply(boundMethod, [this, parameters]);
|
||||||
|
} else if (_instances.containsKey(callback)) {
|
||||||
|
return _callMethod(_instances[callback], 'run', parameters);
|
||||||
} else {
|
} else {
|
||||||
// Assume it's a global function
|
// Assume it's a global function
|
||||||
throw BindingResolutionException(
|
throw BindingResolutionException(
|
||||||
'Global function $callback not found or not callable');
|
'Global function or class $callback not found or not callable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue