Ejemplo n.º 1
0
 public static void TryAddScopedWorkerService <TService, TImplementation>(this IServiceCollection collection)
     where TService : class
     where TImplementation : class, TService
 {
     if (typeof(IDisposable).IsAssignableFrom(typeof(TService)) || typeof(IDisposable).IsAssignableFrom(typeof(TImplementation)))
     {
         collection.TryAddTransient <TImplementation>();
         collection.TryAddTransient(typeof(TService), x => WorkerServiceScope.AddTransientDisposableServices((IDisposable)x.GetService(typeof(TImplementation))));
     }
     else
     {
         collection.TryAddTransient <TService, TImplementation>();
     }
 }
 public void OnPerformed(PerformedContext filterContext)
 {
     WorkerServiceScope.DestroyScope();
 }