/// <summary> /// Adds new type info to the instance /// </summary> /// <param name="factory">factory to create instances from</param> /// <param name="contract">contract type</param> /// <param name="implementation">implementation type</param> /// <param name="proxy">proxy type</param> /// <param name="componentId">component id</param> /// <param name="typeId">type id</param> /// <exception cref ="ArgumentNullException">one or more arguments is null</exception> /// <exception cref ="ArgumentException">one or more arguments does not match</exception> /// <returns>newly created typeInformation</returns> internal TypeInformation Add(ITypeFactory factory, Type contract, Type implementation, Type proxy, Guid componentId, Guid typeId) { if (null == factory) { throw new ArgumentNullException("factory"); } if (null == contract) { throw new ArgumentNullException("contract"); } if (null == implementation) { throw new ArgumentNullException("implementation"); } if (null == proxy) { throw new ArgumentNullException("proxy"); } #if DEBUG if (this.Any(e => e.Contract == contract)) { throw new ArgumentException("Duplicated contract in type cache detected."); } if (!factory.ContainsType(contract)) { throw new ArgumentException("Factory does not support the target contract."); } if (!factory.ContainsType(implementation)) { throw new ArgumentException("Factory does not support the target implementation."); } #endif if (!contract.IsInterface) { throw new ArgumentException("contract is not an interface."); } if (implementation.IsInterface) { throw new ArgumentException("implementation must be a class."); } if (!proxy.IsCOMObject) { throw new ArgumentException("proxy must be a com object."); } TypeInformation result = null; var coClassSource = CoClassSourceAttribute.TryGet(contract, typeId); if (null != coClassSource) { contract = coClassSource.Value; } lock (_thisLock) { result = new TypeInformation(factory, contract, implementation, proxy, componentId, typeId); Add(result); } return(result); }