Esempio n. 1
0
        private void AddBindingForType(Type type, IBinding binding)
        {
            NamedBindings descriptor = bindings.Get(type, () => new NamedBindings(type));

            bindings[type] = descriptor;
            descriptor.Add(binding);
        }
Esempio n. 2
0
        private void RemoveBindingForType(Type type, IBinding binding)
        {
            NamedBindings descriptor = bindings.Get(type, () => null);

            if (descriptor != null)
            {
                descriptor.Remove(binding);
            }
        }
Esempio n. 3
0
        private IBinding GetBinding(Type type, string name)
        {
            NamedBindings descriptor = bindings.Get(type);

            if (descriptor == null)
            {
                return(null);
            }

            IBinding binding = descriptor.GetBinding(name);

            if (binding != null)
            {
                return(binding);
            }
            return(null);
        }
Esempio n. 4
0
        private bool TryCreateBindingFromGeneric(Type type, string name)
        {
            Type          definition = type.GetGenericTypeDefinition();
            NamedBindings descriptor = this.bindings.Get(definition);

            if (descriptor == null)
            {
                return(false);
            }

            IBinding genericBinding = descriptor.GetBinding(name);

            if (genericBinding == null)
            {
                return(false);
            }

            IBinding concreteBinding = Binding.CreateFromGeneric(genericBinding, type.GetGenericArguments());

            this.Add(concreteBinding);
            return(true);
        }