Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

33 lines
1.2KB

  1. using AspectCore.DynamicProxy;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using Microsoft.Extensions.Logging;
  4. using HealthMonitor.Core.Pipeline;
  5. using HealthMonitor.Core.Pipeline.Aop;
  6. using HealthMonitor.Core.Pipeline.Aop.Delete;
  7. namespace HealthMonitor.Core.Aop
  8. {
  9. [AttributeUsage(AttributeTargets.Method, Inherited = false)]
  10. public class DeleteCacheInterceptorAttribute : AbstractInterceptorAttribute
  11. {
  12. public DeleteCacheInterceptorAttribute() { }
  13. public async override Task Invoke(AspectContext context, AspectDelegate next)
  14. {
  15. var pipeContext = new CacheInterceptorContext()
  16. {
  17. AopContext = context,
  18. AopDelegate = next,
  19. Logger = context.ServiceProvider.GetService<ILogger<DeleteCacheInterceptorAttribute>>()!
  20. };
  21. var pipeline = new AopCachePipeline();
  22. pipeline.AddValue(new AssertValidDeleteValue());
  23. //pipeline.AddValue(new TryRemoveRefManagerValue());
  24. pipeline.AddValue(new DeleteEntityCacheValue());
  25. pipeline.AddValue(new AopEndPipeValue());
  26. await pipeline.Start(pipeContext);
  27. }
  28. }
  29. }