private IRootContainer ReplaceInternal <TC>(Func <TC> expression, string serviceName) where TC : class { Type interfaceType = typeof(TC); var serviceMeta = new ServiceInfo <TC, TC>(expression, BaseServiceInfo.GetDecorators(interfaceType), serviceName); ServicesMapTable.AddOrReplace(interfaceType, serviceMeta); //send update to observer ContractObserver.Update(interfaceType); return(this); }
/// <summary> /// Returns <see cref="BaseServiceInfo"/> of specified <paramref name="contractType"/> and <paramref name="serviceName"/>. /// </summary> /// <param name="contractType"></param> /// <param name="serviceName"></param> /// <returns></returns> public new BaseServiceInfo GetServiceInfo(Type contractType, string serviceName) { if (!ServicesMapTable.Contains(contractType)) { throw ExceptionHelper.ThrowServiceNotRegisteredException(contractType.Name); } if (string.IsNullOrEmpty(serviceName)) { return(ServicesMapTable[contractType]); } { return(ServicesMapTable[contractType, serviceName]); } }
/// <summary> /// Get service types that are implemented given contract type /// </summary> /// <param name="contractType"></param> /// <returns></returns> public IEnumerable <ServiceTypeInfo> GetServiceTypes(Type contractType) { return(ServicesMapTable.GetServiceTypes(contractType)); }
/// <summary> /// Get all contract types /// </summary> /// <returns></returns> public IEnumerable <Type> GetAllInterfaces() { return(ServicesMapTable.GetAllContracts()); }