Example #1
0
        internal IBinding GetOrBuildBinding(IBindingBuilder builder)
        {
            if (_currentlyBuilding.Contains(builder))
            {
                throw new BindingRecursionException();
            }

            if (!_bindingsByBuilder.TryGetValue(builder, out var binding))
            {
                _currentlyBuilding.Add(builder);

                _bindingsByBuilder[builder] = binding = builder.Build();

                if (!_bindings.TryGetValue(binding.ServiceType, out var bindingsSet))
                {
                    _bindings[binding.ServiceType] = bindingsSet = new HashSet <IBinding>();
                }

                bindingsSet.Add(binding);

                _currentlyBuilding.Remove(builder);
            }

            return(binding);
        }
Example #2
0
        internal IBinding GetOrBuildBinding(IBindingBuilder bindingBuilder)
        {
            if (_currentlyBuilding.Contains(bindingBuilder))
            {
                throw new BindingRecursionException();
            }

            if (!_bindings.TryGetValue(bindingBuilder, out var binding))
            {
                _currentlyBuilding.Add(bindingBuilder);

                _bindings[bindingBuilder] = binding = bindingBuilder.Build();
            }

            return(binding);
        }