You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 line
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.Update;
  7. namespace HealthMonitor.Core.Aop
  8. {
  9. [AttributeUsage(AttributeTargets.Method, Inherited = false)]
  10. public class InsertCacheInterceptorAttribute : AbstractInterceptorAttribute
  11. {
  12. public InsertCacheInterceptorAttribute() { }
  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<InsertCacheInterceptorAttribute>>()!
  20. };
  21. var pipeline = new AopCachePipeline();
  22. pipeline.AddValue(new AssertValidUpdateValue());
  23. //pipeline.AddValue(new TryModifyRefManagerValue(false));
  24. pipeline.AddValue(new UpdateEntityCacheValue());
  25. pipeline.AddValue(new AopEndPipeValue());
  26. await pipeline.Start(pipeContext);
  27. }
  28. }
  29. }