buildBinding method
Bir map yap buildde Bu mapde callingler bulunsun
Implementation
@override
void buildBinding() {
super.buildBinding();
var _callings = <PathSegment, Binding>{};
PathSegment? arg;
for (var child in children) {
var _childCalling = child.visitCallingChildren(TreeVisitor((visitor) {
if (visitor.currentValue is GatewayCalling) {
visitor.stop();
return;
}
if (visitor.currentValue is RouteCalling) {
visitor.stop();
}
}));
if (_childCalling.result == null) {
throw UnsupportedError("Each Gateway child (or Service child) must have"
"[Route] in the tree."
"\nwhere: child ${child.component} in $_errorWhere");
}
if (_childCalling.result is GatewayCalling) {
var segments = ((_childCalling.result! as GatewayCalling).binding
as GatewayBinding)
.calling
.childrenBinding;
for (var seg in segments.entries) {
if (seg.key.isArgument) {
if (arg != null) {
throw Exception("Gateways allow only once argument segment."
"\nbut found $arg and"
" $seg\nWHERE: $_errorWhere");
} else {
arg = seg.key;
}
}
_callings[seg.key] = child;
}
} else {
var seg =
(_childCalling.result! as RouteCalling).binding.component.segment;
if (seg.isArgument) {
if (arg != null) {
throw Exception("Gateways allow only once argument segment."
" \nbut found $arg and"
" $seg\nWHERE: $_errorWhere");
} else {
arg = seg;
}
}
_callings[seg] = child;
}
}
//
// print(
// "${_callings.map((key, value) => MapEntry(key, value.))}");
calling.childrenBinding = _callings;
}