public virtual IEnumerable <object> GetAllComponents(Type contract, string name) { ComponentContextUtils.ThrowIfNotContract(contract); var identity = new ContractIdentity(contract, name); var factories = _repository.FindFactories(identity); return(factories .Select(f => f.GetComponentInstance(identity, _compositionListeners.Values)) .Where(result => result != null)); }
public virtual object GetComponent(Type contract, string name) { ComponentContextUtils.ThrowIfNotContract(contract); if (contract.ContainsGenericParameters) { throw new CompositionException("Requested contract type " + contract.Name + " contains open generic parameters. Can not construct a concrete type."); } var identity = new ContractIdentity(contract, name); var factories = _repository.FindFactories(identity); return(factories .Select(f => f.GetComponentInstance(identity, _compositionListeners.Values)) .FirstOrDefault(result => result != null)); }
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) { ComponentContextUtils.ThrowIfNotContract(contract); } factory.Initialize(this); _repository.Add(new ContractIdentity(contract, name), factory); }