/// <inheritdoc/> public TenantId Resolve(TenantStrategy tenantStrategy, HttpRequest httpRequest) { var strategiesThatCanResolveTenant = _tenantResolvers.Where(_ => _.Strategy.Value.Equals(tenantStrategy.Value)).ToArray(); var length = strategiesThatCanResolveTenant.Length; if (length == 0) { throw new CouldNotFindStrategy(tenantStrategy); } if (length > 1) { throw new MultipleStrategiesFound(tenantStrategy); } return(strategiesThatCanResolveTenant[0].ResolveTenant((strategyType) => _tenantMapManager.InstanceOfStrategy(strategyType), httpRequest)); }
/// <summary> /// Instantiates an instance of <see cref="MultipleStrategiesFound"/> /// </summary> /// <param name="tenantStrategy"></param> public MultipleStrategiesFound(TenantStrategy tenantStrategy) : base($"Found multiple strategies for the {tenantStrategy.Value} strategy") { }
/// <summary> /// Instantiates an instance of <see cref="CouldNotFindStrategy"/> /// </summary> /// <param name="tenantStrategy"></param> public CouldNotFindStrategy(TenantStrategy tenantStrategy) : base($"Could not find a strategy to resolve tenants for the '{tenantStrategy.Value}' strategy") { }