create static method
ServiceDescriptor
create(
- Type serviceType,
- FutureOr instantiate(
- Injector
- Type? bindingType,
- bool optional = false,
- List<
InjectorKey> publications = const [], - List<
InjectorKey> dependencies = const [], - List<
InjectorKey> optionalDependencies = const [], - List<
Condition> conditions = const [], - FutureOr<
void> start(- DarwinSystem,
- dynamic
- FutureOr<
void> stop(- DarwinSystem,
- dynamic
Implementation
static ServiceDescriptor create(
Type serviceType,
FutureOr<dynamic> Function(Injector) instantiate, {
Type? bindingType,
bool optional = false,
List<InjectorKey> publications = const [],
List<InjectorKey> dependencies = const [],
List<InjectorKey> optionalDependencies = const [],
List<Condition> conditions = const [],
FutureOr<void> Function(DarwinSystem, dynamic)? start,
FutureOr<void> Function(DarwinSystem, dynamic)? stop,
}) {
var actualBindingType = bindingType ?? serviceType;
var publicationList = publications.toList();
if (!publicationList.any((element) => element.type == actualBindingType)) {
publicationList.add(InjectorKey.create(actualBindingType));
}
return ServiceDescriptorImpl(
bindingType: actualBindingType,
serviceType: serviceType,
optional: optional,
conditions: conditions,
dependencies: dependencies,
optionalDependencies: optionalDependencies,
publications: publicationList,
instantiateFunc: instantiate,
startFunc: start ?? _lifecycleNoop,
stopFunc: stop ?? _lifecycleNoop);
}