Ejemplo n.º 1
0
        /// <summary>
        /// Add components for constructing tenant-specific Gremlin containers.
        /// </summary>
        /// <param name="services">The target service collection.</param>
        /// <param name="getOptions">Function to get the configuration options.</param>
        /// <returns>The service collection.</returns>
        public static IServiceCollection AddTenantGremlinContainerFactory(
            this IServiceCollection services,
            Func <IServiceProvider, TenantGremlinContainerFactoryOptions> getOptions)
        {
            ArgumentNullException.ThrowIfNull(services);

            if (services.Any(s => typeof(ITenantGremlinContainerFactory).IsAssignableFrom(s.ServiceType)))
            {
                return(services);
            }

            services.AddRequiredTenancyServices();

            services.AddSingleton <ITenantGremlinContainerFactory>(s =>
            {
                TenantGremlinContainerFactoryOptions options = getOptions(s);
                return(new TenantGremlinContainerFactory(options));
            });
            return(services);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds services required by tenancy Gremlin based stores.
 /// </summary>
 /// <param name="services">The service collection.</param>
 /// <param name="options">Configuration for the TenantGremlinContainerFactory.</param>
 /// <returns>The modified service collection.</returns>
 public static IServiceCollection AddTenantGremlinContainerFactory(
     this IServiceCollection services,
     TenantGremlinContainerFactoryOptions options)
 {
     return(services.AddTenantGremlinContainerFactory(_ => options));
 }