/// <summary>
        /// Adds the root tenant to the collection, using the <see cref="ITenancyService"/>.
        /// </summary>
        /// <param name="services">The service collection to which to add the root tenant.</param>
        /// <returns>The configured service collection.</returns>
        public static IServiceCollection AddTenantServiceClientRootTenant(this IServiceCollection services)
        {
            if (services.Any(s => typeof(RootTenant).IsAssignableFrom(s.ServiceType)))
            {
                return(services);
            }

            services.AddContent(contentFactory => contentFactory.RegisterTransientContent <Tenant>());

            // Construct a root tenant from the tenant retrieved from the service, using the
            // root tenant ID.
            services.AddSingleton(s =>
            {
                ITenancyService tenancyService         = s.GetRequiredService <ITenancyService>();
                ITenantMapper tenantMapper             = s.GetRequiredService <ITenantMapper>();
                IPropertyBagFactory propertyBagFactory = s.GetRequiredService <IPropertyBagFactory>();
                ITenant fetchedRootTenant = tenantMapper.MapTenant(tenancyService.GetTenant(RootTenant.RootTenantId));
                var localRootTenant       = new RootTenant(propertyBagFactory);
                IReadOnlyDictionary <string, object> propertiesToSetOrAdd = fetchedRootTenant.Properties.AsDictionary();
                localRootTenant.UpdateProperties(propertiesToSetOrAdd);
                return(localRootTenant);
            });

            return(services);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ClientTenantProvider"/> class.
 /// </summary>
 /// <param name="root">The Root tenant.</param>
 /// <param name="tenantService">The tenant service.</param>
 /// <param name="tenantMapper">The tenant mapper to use.</param>
 /// <param name="jsonSerializerSettingsProvider">The JSON serializer settings provider.</param>
 public ClientTenantStore(
     RootTenant root,
     ITenancyService tenantService,
     ITenantMapper tenantMapper,
     IJsonSerializerSettingsProvider jsonSerializerSettingsProvider)
     : base(root, tenantService, tenantMapper)
 {
     this.jsonSerializerSettingsProvider = jsonSerializerSettingsProvider
                                           ?? throw new ArgumentNullException(nameof(jsonSerializerSettingsProvider));
 }
 public WebhookCoordinator(
     ITenantMapper tenantMapper,
     FactoryFor <IWebhookScheduler> schedulerFactory,
     IExecutionContextManager executionContextManager
     )
 {
     _tenantMapper            = tenantMapper;
     _schedulerFactory        = schedulerFactory;
     _executionContextManager = executionContextManager;
 }
Esempio n. 4
0
 public SmsEagleController(
     ITenantMapper mapper,
     IExecutionContextManager contextManager,
     ICommandCoordinator commandCoordinator,
     ILogger logger)
 {
     _mapper             = mapper;
     _contextManager     = contextManager;
     _commandCoordinator = commandCoordinator;
     _logger             = logger;
 }
Esempio n. 5
0
 public GatewayEventProcessor(ITenantMapper mapper, IExecutionContextManager contextManager)
 {
     _mapper         = mapper;
     _contextManager = contextManager;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ClientTenantProvider"/> class.
 /// </summary>
 /// <param name="root">The Root tenant.</param>
 /// <param name="tenantService">The tenant service.</param>
 /// <param name="tenantMapper">The tenant mapper to use.</param>
 public ClientTenantProvider(RootTenant root, ITenancyService tenantService, ITenantMapper tenantMapper)
 {
     this.Root          = root ?? throw new ArgumentNullException(nameof(root));
     this.TenantService = tenantService ?? throw new ArgumentNullException(nameof(tenantService));
     this.TenantMapper  = tenantMapper ?? throw new ArgumentNullException(nameof(tenantMapper));
 }