コード例 #1
0
        /// <summary>
        /// Add components for constructing tenant-specific table storage 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 AddTenantCloudTableFactory(
            this IServiceCollection services,
            Func <IServiceProvider, TenantCloudTableFactoryOptions> getOptions)
        {
            ArgumentNullException.ThrowIfNull(services);

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

            services.AddRequiredTenancyServices();

            services.AddSingleton <ITenantCloudTableFactory>(s =>
            {
                TenantCloudTableFactoryOptions options = getOptions(s);

                return(new TenantCloudTableFactory(options));
            });

            return(services);
        }
コード例 #2
0
 /// <summary>
 /// Adds services required by tenancy Azure storage based stores.
 /// </summary>
 /// <param name="services">The service collection.</param>
 /// <param name="options">Configuration for the TenantCloudTableFactory.</param>
 /// <returns>The modified service collection.</returns>
 public static IServiceCollection AddTenantCloudTableFactory(
     this IServiceCollection services,
     TenantCloudTableFactoryOptions options)
 {
     return(services.AddTenantCloudTableFactory(_ => options));
 }