Beispiel #1
0
 private static InvalidOperationException GetAnOverlappingGenericRegistrationExistsException(
     IProducerProvider providerToRegister, IProducerProvider overlappingProvider) =>
 new InvalidOperationException(
     StringResources.AnOverlappingRegistrationExists(
         providerToRegister.ServiceType,
         overlappingProvider.ImplementationType,
         overlappingProvider.IsConditional,
         providerToRegister.ImplementationType,
         providerToRegister.IsConditional));
Beispiel #2
0
        private void ThrowWhenIdenticalImplementationIsAlreadyRegistered(
            InstanceProducer producerToRegister)
        {
            // A provider overlaps the providerToRegister when it can be applied to ALL generic
            // types that the providerToRegister can be applied to as well.
            var overlappingProducers = this.GetOverlappingProducers(producerToRegister);

            bool isReplacement =
                producerToRegister.IsUnconditional && this.container.Options.AllowOverridingRegistrations;

            if (!isReplacement && overlappingProducers.Any())
            {
                var overlappingProducer = overlappingProducers.FirstOrDefault();

                throw new InvalidOperationException(
                          StringResources.AnOverlappingRegistrationExists(
                              producerToRegister.ServiceType,
                              overlappingProducer.FinalImplementationType,
                              overlappingProducer.IsConditional,
                              producerToRegister.FinalImplementationType,
                              producerToRegister.IsConditional));
            }
        }