Пример #1
0
        public static Task ClearDownTransientTenantContentStore(FeatureContext context)
        {
            return(context.RunAndStoreExceptionsAsync(async() =>
            {
                ITenant currentTenant = context.GetTransientTenant();

                if (currentTenant != null)
                {
                    IServiceProvider serviceProvider = ContainerBindings.GetServiceProvider(context);
                    ITenantCosmosContainerFactory containerFactory = serviceProvider.GetRequiredService <ITenantCosmosContainerFactory>();
                    CosmosContainerDefinition containerDefinition = serviceProvider.GetRequiredService <CosmosContainerDefinition>();
                    Container container = await containerFactory.GetContainerForTenantAsync(currentTenant, containerDefinition).ConfigureAwait(false);
                    await container.DeleteContainerAsync().ConfigureAwait(false);
                }
            }));
        }
 /// <summary>
 /// Retrieves the Id of the transient tenant created for the current feature from the supplied feature context.
 /// <see cref="FeatureContext"/>.
 /// </summary>
 /// <param name="context">The current <see cref="FeatureContext"/>.</param>
 /// <returns>The Id of the <see cref="ITenant"/>.</returns>
 /// <exception cref="ArgumentNullException">There is no current tenant.</exception>
 public static string GetTransientTenantId(this FeatureContext context)
 {
     return(context.GetTransientTenant().Id);
 }