Esempio n. 1
0
 public ITenantShellAccessor <TTenant> WithTenant(TenantDistinguisher tenantDistinguisher)
 {
     CurrentTenantShell = new Lazy <Task <TenantShell <TTenant> > >(async() =>
     {
         return(await _tenantResolver.ResolveTenant(tenantDistinguisher, _tenantFactory));
     });
     return(this);
 }
Esempio n. 2
0
        public TenantShellAccessor(ITenantShellFactory <TTenant> tenantFactory,
                                   TenantDistinguisherAccessor <TTenant> tenantDistinguisherAccessor,
                                   ITenantShellResolver <TTenant> tenantResolver)
        {
            _tenantFactory = tenantFactory;
            _tenantDistinguisherAccessor = tenantDistinguisherAccessor;
            _tenantResolver = tenantResolver;

            CurrentTenantShell = new Lazy <Task <TenantShell <TTenant> > >(async() =>
            {
                var identifier = await _tenantDistinguisherAccessor.TenantDistinguisher.Value;
                if (identifier == null)
                {
                    return(null);
                }

                return(await _tenantResolver.ResolveTenant(identifier, _tenantFactory));
            });
        }
        public TenantShellAccessor(ITenantShellFactory <TTenant> tenantFactory,
                                   TenantDistinguisherAccessor <TTenant> tenantDistinguisherAccessor,
                                   ITenantShellResolver <TTenant> tenantResolver)
        {
            _tenantFactory = tenantFactory;
            _tenantDistinguisherAccessor = tenantDistinguisherAccessor;
            _tenantResolver = tenantResolver;

            CurrentTenantShell = new Lazy <Task <TenantShell <TTenant> > >(async() =>
            {
                // return new Task<TTenant>(async () =>
                //{
                var identifier = await _tenantDistinguisherAccessor.TenantDistinguisher.Value;
                if (identifier == null)
                {
                    return(null);
                }

                // grab the tenant id for the context id.
                // if we don't have one then
                var tenantShell = await _tenantResolver.ResolveTenant(identifier, _tenantFactory);
                return(tenantShell);
            });
        }