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,9 +1,21 @@
|
||||
import 'package:benchmark_di/scenarios/universal_chain_module.dart';
|
||||
|
||||
/// Универсальная абстракция для DI-адаптера с унифицированной функцией регистрации.
|
||||
/// Теперь для каждого адаптера задаём строгий generic тип контейнера.
|
||||
typedef Registration<TContainer> = void Function(TContainer);
|
||||
|
||||
abstract class DIAdapter<TContainer> {
|
||||
/// Устанавливает зависимости с помощью строго типизированного контейнера.
|
||||
void setupDependencies(void Function(TContainer container) registration);
|
||||
|
||||
/// Возвращает типобезопасную функцию регистрации зависимостей под конкретный сценарий.
|
||||
Registration<TContainer> universalRegistration<S extends Enum>({
|
||||
required S scenario,
|
||||
required int chainCount,
|
||||
required int nestingDepth,
|
||||
required UniversalBindingMode bindingMode,
|
||||
});
|
||||
|
||||
/// Резолвит (возвращает) экземпляр типа [T] (по имени, если требуется).
|
||||
T resolve<T extends Object>({String? named});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user