Abp.Runtime.IAmbientScopeProvider.BeginScope(string, bool)

Here are the examples of the csharp api class Abp.Runtime.IAmbientScopeProvider.BeginScope(string, bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: aspnetboilerplate
Source File: TenantResolver.cs
View license
public int? ResolveTenantId()
        {
            if (!_multiTenancy.Resolvers.Any())
            {
                return null;
            }

            if (_ambientScopeProvider.GetValue(AmbientScopeContextKey))
            {
                //Preventing recursive call of ResolveTenantId
                return null;
            }

            using (_ambientScopeProvider.BeginScope(AmbientScopeContextKey, true))
            {
                var cacheItem = _cache.Value;
                if (cacheItem != null)
                {
                    return cacheItem.TenantId;
                }

                var tenantId = GetTenantIdFromContributors();
                _cache.Value = new TenantResolverCacheItem(tenantId);
                return tenantId;
            }
        }