update: updating 29 pass 5 fail

This commit is contained in:
Patrick Stewart 2024-12-22 18:03:00 -07:00
parent 4f0f129900
commit 48c6ca8785

View file

@ -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');
} }
} }