/// <summary> /// Adds the specified <paramref name="descriptor"/> to the <paramref name="collection"/> if the /// service type hasn't already been registered. /// </summary> /// <param name="collection">The <see cref="IRegistrationCollection"/>.</param> /// <param name="descriptor">The <see cref="RegistrationDescriptor"/> to add.</param> public static void TryAdd( this IRegistrationCollection collection, RegistrationDescriptor descriptor) { if (collection is null) { throw new ArgumentNullException(nameof(collection)); } if (descriptor is null) { throw new ArgumentNullException(nameof(descriptor)); } if (!collection.Any(d => d.ServiceType == descriptor.ServiceType)) { collection.Add(descriptor); } }