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.

AopCachePipeline.cs 979B

12345678910111213141516171819202122232425262728293031323334
  1. using HealthMonitor.Core.Pipeline.Aop;
  2. namespace HealthMonitor.Core.Pipeline
  3. {
  4. public class AopCachePipeline : IPipeline<CacheInterceptorContext>
  5. {
  6. private readonly IList<IValue<CacheInterceptorContext>> _values;
  7. public AopCachePipeline()
  8. {
  9. _values = new List<IValue<CacheInterceptorContext>>();
  10. }
  11. public void AddValue(IValue<CacheInterceptorContext> v)
  12. {
  13. var lastValue = _values.LastOrDefault();
  14. if (lastValue != null) lastValue.Next = v;
  15. _values.Add(v);
  16. }
  17. public async Task Start(CacheInterceptorContext context)
  18. {
  19. try
  20. {
  21. var firstValue = _values.FirstOrDefault();
  22. if (firstValue != null) await firstValue.Invoke(context);
  23. }
  24. catch (AssertValidException)
  25. {
  26. await context.AopDelegate(context.AopContext);
  27. }
  28. }
  29. }
  30. }