private void InternalRegister(Type contract, string name, IComponentFactory factory,
                                      bool performChecking)
        {
            if (contract == null)
            {
                throw new ArgumentNullException(nameof(contract));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            if (performChecking && !Configuration.DisableAttributeChecking)
            {
                ComponentContextUtils.ThrowIfNotContract(contract);
            }

            if (!factory.ValidateContractType(contract))
            {
                throw new CompositionException("This component type / factory cannot be registered with the contract " +
                                               $"{contract.FullName}. The component type is not assignable to the contract " +
                                               "or the factory logic prevents such registration.");
            }

            factory.Initialize(this);

            _repository.Add(new ContractIdentity(contract, name), factory);
        }