src/Microsoft/DependencyInjection/0.Abstractions/src/Extensions/StaticLifetimeServicesExtension{`4}.cs
/// <summary>
/// Adds <paramref name="descriptor"/> if an existing descriptor with the same
/// service type and an implementation that does not already exist in 
/// <paramref name="collection."/>.
/// </summary>
/// <param name="collection"></param>
/// <param name="descriptor"></param>
/// <remarks>Prevents the registration of implementation type duplicates.</remarks>
Adds  if an existing descriptor with the same
service type and an implementation that does not already exist in
.
Adds if an existing descriptor with the same service type and an implementation that does not already exist in .
public void TryAddEnumerable(TCollection collection, TDescriptor descriptor)
        {
            if (collection is null) {
                throw new ArgumentNullException(nameof(collection));
            }
            if (descriptor == null) {
                throw new ArgumentNullException(nameof(descriptor));
            }
            if (collection.Any(collectionDescriptor => {
                return collectionDescriptor.ServiceType == descriptor.ServiceType
                    && collectionDescriptor.GetImplementationType() == descriptor.GetImplementationType();
            })) {
                return;
            }
            collection.Add(descriptor);
        }
public void TryAddEnumerable ( TCollection collection , TDescriptor descriptor ) { if ( collection is null ) { throw new ArgumentNullException ( nameof ( collection ) ) ; } if ( descriptor == null ) { throw new ArgumentNullException ( nameof ( descriptor ) ) ; } if ( collection . Any ( collectionDescriptor => { return collectionDescriptor . ServiceType == descriptor . ServiceType && collectionDescriptor . GetImplementationType ( ) == descriptor . GetImplementationType ( ) ; } ) ) { return ; } collection . Add ( descriptor ) ; }
Adds  if an existing descriptor with the same
service type and an implementation that does not already exist in
.
Adds if an existing descriptor with the same service type and an implementation that does not already exist in .
collection
TCollection
None
descriptor
TDescriptor
None
remarks
Prevents the registration of implementation type duplicates.
Prevents the registration of implementation type duplicates .