mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 21:57:58 +00:00
refactor(structure): move benchmarks, scenarios, adapters, utils to dedicated folders; update imports/project layout
This commit is contained in:
42
benchmark_cherrypick/lib/scenarios/chain_factory_module.dart
Normal file
42
benchmark_cherrypick/lib/scenarios/chain_factory_module.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
// === DI graph: A -> B -> C (factory/no singleton) ===
|
||||
import 'package:cherrypick/cherrypick.dart';
|
||||
|
||||
import 'service.dart';
|
||||
import 'service_impl.dart';
|
||||
|
||||
class ChainFactoryModule extends Module {
|
||||
// количество независимых цепочек
|
||||
final int chainCount;
|
||||
|
||||
// глубина вложенности
|
||||
final int nestingDepth;
|
||||
|
||||
ChainFactoryModule({
|
||||
required this.chainCount,
|
||||
required this.nestingDepth,
|
||||
});
|
||||
|
||||
@override
|
||||
void builder(Scope currentScope) {
|
||||
for (var chainIndex = 0; chainIndex < chainCount; chainIndex++) {
|
||||
for (var levelIndex = 0; levelIndex < nestingDepth; levelIndex++) {
|
||||
final chain = chainIndex + 1;
|
||||
final level = levelIndex + 1;
|
||||
|
||||
final prevDepName = '${chain.toString()}_${(level - 1).toString()}';
|
||||
final depName = '${chain.toString()}_${level.toString()}';
|
||||
|
||||
bind<Service>()
|
||||
.toProvide(
|
||||
() => ServiceImpl(
|
||||
value: depName,
|
||||
dependency: currentScope.tryResolve<Service>(
|
||||
named: prevDepName,
|
||||
),
|
||||
),
|
||||
)
|
||||
.withName(depName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user