using AspectCore.DynamicProxy; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using HealthMonitor.Core.Pipeline; using HealthMonitor.Core.Pipeline.Aop; using HealthMonitor.Core.Pipeline.Aop.Query; namespace HealthMonitor.Core.Aop { [AttributeUsage(AttributeTargets.Method, Inherited = false)] public class QueryCacheInterceptorAttribute : AbstractInterceptorAttribute { public QueryCacheInterceptorAttribute() { } public async override Task Invoke(AspectContext context, AspectDelegate next) { var pipeContext = new CacheInterceptorContext() { AopContext = context, AopDelegate = next, Logger = context.ServiceProvider.GetService>()! }; var pipeline = new AopCachePipeline(); pipeline.AddValue(new AssertValidQueryValue()); pipeline.AddValue(new TryGetRefManagerValue()); pipeline.AddValue(new GetOrInsertEntityCacheValue()); pipeline.AddValue(new AopEndPipeValue()); await pipeline.Start(pipeContext); } } }