Example #1
0
 /// <summary>
 /// Do synchronous operations in scoped service context.
 /// </summary>
 /// <param name="services">The service provider to create the scope.</param>
 /// <param name="scopeContent">The scope runner.</param>
 public static void RunScoped(
     this SubstrateApplicationBase services,
     Action <IServiceProvider> scopeContent)
 {
     using var scope = services.Services.CreateScope();
     scopeContent.Invoke(scope.ServiceProvider);
 }
Example #2
0
 /// <summary>
 /// Do asynchronous operations in scoped service context.
 /// </summary>
 /// <param name="services">The service provider to create the scope.</param>
 /// <param name="scopeContent">The scope runner.</param>
 /// <returns>The task for running the scoped operation.</returns>
 public static async Task RunScoped(
     this SubstrateApplicationBase services,
     Func <IServiceProvider, Task> scopeContent)
 {
     using var scope = services.Services.CreateScope();
     await scopeContent.Invoke(scope.ServiceProvider);
 }
Example #3
0
 /// <summary>
 /// Add the application accessor for tests.
 /// </summary>
 /// <param name="builder">The <see cref="IHostBuilder"/></param>
 /// <param name="base">The substrate application to test</param>
 /// <returns>The <see cref="IHostBuilder"/></returns>
 public static IHostBuilder MarkTest(this IHostBuilder builder, SubstrateApplicationBase @base)
 {
     builder.ConfigureServices(svcs => svcs.AddSingleton <IApplicationAccessor>(new DefaultAccessor(@base)));
     return(builder);
 }
Example #4
0
 public DefaultAccessor(SubstrateApplicationBase @base)
 {
     Instance = @base;
 }