71 lines
2.0 KiB
C#
71 lines
2.0 KiB
C#
//using AspectCore.DynamicProxy;
|
|
////using System;
|
|
//using System.Collections.Generic;
|
|
//using System.Linq;
|
|
//using System.Reflection;
|
|
//using System.Text;
|
|
//using System.Threading;
|
|
//using System.Threading.Tasks;
|
|
|
|
//namespace Store.Framework.Attributes
|
|
//{
|
|
// /// <summary>
|
|
// /// Aop延迟时间
|
|
// /// </summary>
|
|
// ///
|
|
// public class SleepAttribute : AopInterceptorAttribute
|
|
// {
|
|
// /// <summary>
|
|
// /// 毫秒
|
|
// /// </summary>
|
|
// public int Millisecond { get; set; }
|
|
// /// <summary>
|
|
// /// 间隔区间
|
|
// /// </summary>
|
|
// public Tuple<int, int> ExtentMillisecond { get; set; }
|
|
// /// <summary>
|
|
// /// 执行位置
|
|
// /// </summary>
|
|
// public ExecOrder Location { get; set; } = ExecOrder.Before;
|
|
// public SleepAttribute(int millisecond)
|
|
// {
|
|
// Millisecond = millisecond;
|
|
// }
|
|
// public SleepAttribute(int StartMillisecond, int EndMillisecond)
|
|
// {
|
|
// ExtentMillisecond = new Tuple<int, int>(StartMillisecond, EndMillisecond);
|
|
// }
|
|
// public override void BeforeAction(AspectContext context)
|
|
// {
|
|
// if (Location == ExecOrder.Before)
|
|
// Exec();
|
|
// }
|
|
|
|
// public override void AfterAction(AspectContext context)
|
|
// {
|
|
// if (Location == ExecOrder.After)
|
|
// Exec();
|
|
// }
|
|
|
|
// private void Exec()
|
|
// {
|
|
// if (ExtentMillisecond != null)
|
|
// {
|
|
// Millisecond = new Random().Next(ExtentMillisecond.Item1, ExtentMillisecond.Item2);
|
|
// }
|
|
// Thread.Sleep(Millisecond);
|
|
// }
|
|
// public enum ExecOrder
|
|
// {
|
|
// /// <summary>
|
|
// /// 方法执行前
|
|
// /// </summary>
|
|
// Before,
|
|
// /// <summary>
|
|
// /// 方法执行后
|
|
// /// </summary>
|
|
// After
|
|
// }
|
|
// }
|
|
//}
|