create static method

ServiceDescriptor create(
  1. Type serviceType,
  2. FutureOr instantiate(
    1. Injector
    ), {
  3. Type? bindingType,
  4. bool optional = false,
  5. List<InjectorKey> publications = const [],
  6. List<InjectorKey> dependencies = const [],
  7. List<InjectorKey> optionalDependencies = const [],
  8. List<Condition> conditions = const [],
  9. FutureOr<void> start(
    1. DarwinSystem,
    2. dynamic
    )?,
  10. FutureOr<void> stop(
    1. DarwinSystem,
    2. 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);
}