示例#1
0
        public void AddOrUpdateRegistration(IServiceRegistration registration, object registrationName, bool remap, bool replace)
        {
            var newRepository = new ConcurrentOrderedKeyStore <object, IServiceRegistration>();

            newRepository.AddOrUpdate(registrationName, registration);

            if (remap)
            {
                this.serviceRepository.AddOrUpdate(registration.ServiceType, newRepository, (oldValue, newValue) => newValue);
            }
            else
            {
                this.serviceRepository.AddOrUpdate(registration.ServiceType, newRepository,
                                                   (oldValue, newValue) => oldValue.AddOrUpdate(registrationName, registration, replace));
            }
        }
示例#2
0
        /// <inheritdoc />
        public void AddDecorator(Type type, IServiceRegistration serviceRegistration, bool remap, bool replace)
        {
            var newRepository = new ConcurrentOrderedKeyStore <Type, IServiceRegistration>
            {
                { serviceRegistration.ImplementationType, serviceRegistration }
            };

            if (remap)
            {
                this.repository.AddOrUpdate(type, newRepository, (oldValue, newValue) => newValue);
            }
            else
            {
                this.repository.AddOrUpdate(type, newRepository, (oldValue, newValue) => oldValue
                                            .AddOrUpdate(serviceRegistration.ImplementationType, serviceRegistration, replace));
            }
        }