mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
refactor: full generic DIAdapter workflow & universalRegistration abstraction
- Made UniversalChainBenchmark and UniversalChainAsyncBenchmark fully generic with strong typing for DIAdapter<TContainer> - Moved all universalRegistration logic inside adapters; removed global function and typedef - Replaced dynamic/object-based registration with type-safe generic contracts end-to-end - Updated CLI and usage: all DI and scenarios are invoked via type-safe generics - Fixed all analysis errors, Riverpod async/future usages, and imports for full Dart 3 compatibility - All benchmarks fully pass for Cherrypick, GetIt, and Riverpod adapters
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'package:cherrypick/cherrypick.dart';
|
||||
import 'di_adapter.dart';
|
||||
import '../scenarios/universal_chain_module.dart';
|
||||
|
||||
/// Универсальный DIAdapter для CherryPick с поддержкой subScope без дублирования логики.
|
||||
class CherrypickDIAdapter extends DIAdapter<Scope> {
|
||||
Scope? _scope;
|
||||
final bool _isSubScope;
|
||||
@@ -16,6 +16,28 @@ class CherrypickDIAdapter extends DIAdapter<Scope> {
|
||||
registration(_scope!);
|
||||
}
|
||||
|
||||
@override
|
||||
Registration<Scope> universalRegistration<S extends Enum>({
|
||||
required S scenario,
|
||||
required int chainCount,
|
||||
required int nestingDepth,
|
||||
required UniversalBindingMode bindingMode,
|
||||
}) {
|
||||
if (scenario is UniversalScenario) {
|
||||
return (scope) {
|
||||
scope.installModules([
|
||||
UniversalChainModule(
|
||||
chainCount: chainCount,
|
||||
nestingDepth: nestingDepth,
|
||||
bindingMode: bindingMode,
|
||||
scenario: scenario,
|
||||
),
|
||||
]);
|
||||
};
|
||||
}
|
||||
throw UnsupportedError('Scenario $scenario not supported by CherrypickDIAdapter');
|
||||
}
|
||||
|
||||
@override
|
||||
T resolve<T extends Object>({String? named}) =>
|
||||
named == null ? _scope!.resolve<T>() : _scope!.resolve<T>(named: named);
|
||||
|
||||
Reference in New Issue
Block a user