/// <summary> /// Resolves the <c>TenantContext</c> from the configured <c>ITenantStore</c> using the configured <c>ITenantResolverStrategy</c>. /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task <TenantContext> ResolveAsync(object context) { Utilities.TryLogInfo(logger, $"Resolving tenant using \"{multiTenantStrategy.GetType()}\"."); string identifier = multiTenantStrategy.GetIdentifier(context); Utilities.TryLogInfo(logger, $"Tenant identifier \"{identifier ?? "<null>"}\" detected."); if (string.IsNullOrWhiteSpace(identifier)) { return(null); } Utilities.TryLogInfo(logger, $"Retrieving TenantContext using \"{multiTenantStore.GetType()}\"."); var storeResult = await multiTenantStore.GetByIdentifierAsync(identifier).ConfigureAwait(false); Utilities.TryLogInfo(logger, $"TenantContext for Tenant Id \"{storeResult?.Id ?? "<null>"}\" was retrieved."); if (storeResult == null) { return(null); } var result = new TenantContext(storeResult); result.MultiTenantStrategyType = multiTenantStrategy.GetType(); result.MultiTenantStoreType = multiTenantStore.GetType(); return(result); }
/// <summary> /// Resolves the <c>TenantContext</c> from the configured <c>ITenantStore</c> using the configured <c>ITenantResolverStrategy</c>. /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task <TenantContext> ResolveAsync(object context) { string identifier = _multiTenantStrategy.GetIdentifier(context); if (string.IsNullOrWhiteSpace(identifier)) { return(null); } var storeResult = await _multiTenantStore.GetByIdentifierAsync(identifier).ConfigureAwait(false); if (storeResult == null) { return(null); } var result = new TenantContext(storeResult); result.MultiTenantStrategyType = _multiTenantStrategy.GetType(); result.MultiTenantStoreType = _multiTenantStore.GetType(); return(result); }