private void AddBindingForType(Type type, IBinding binding) { NamedBindings descriptor = bindings.Get(type, () => new NamedBindings(type)); bindings[type] = descriptor; descriptor.Add(binding); }
private void RemoveBindingForType(Type type, IBinding binding) { NamedBindings descriptor = bindings.Get(type, () => null); if (descriptor != null) { descriptor.Remove(binding); } }
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); }
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); }