replace method

ServiceCollection replace(
  1. ServiceDescriptor descriptor
)

Removes the first service in ServiceCollection with the same service type as descriptor and adds descriptor to the collection.

Implementation

ServiceCollection replace(ServiceDescriptor descriptor) {
  // Remove existing
  var count = length;
  for (var i = 0; i < count; i++) {
    if (this[i].serviceType == descriptor.serviceType) {
      removeAt(i);
      break;
    }
  }
  add(descriptor);
  return this;
}