58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
//using MAX.Core.Helpers;
|
|
//using Polly;
|
|
//using Store.Framework.HttpResultParser;
|
|
//using System;
|
|
//using System.Collections.Generic;
|
|
//using System.Linq;
|
|
//using System.Text;
|
|
//using System.Threading.Tasks;
|
|
|
|
//namespace Store.Framework.Attributes
|
|
//{
|
|
// /// <summary>
|
|
// /// Http请求请求失败重新尝试 HttpStatusCode 状态不为Ok一律重新尝试
|
|
// /// </summary>
|
|
// [AttributeUsage(AttributeTargets.Method)]
|
|
// public class HttpTryAttribute : AbstractInterceptorAttribute
|
|
// {
|
|
// /// <summary>
|
|
// /// 最大尝试次数
|
|
// /// </summary>
|
|
// public int MaxRetryTimes { get; set; } = 3;
|
|
// /// <summary>
|
|
// /// 重新尝试延迟时间毫秒
|
|
// /// </summary>
|
|
// public int RetryIntervalMilliseconds { get; set; } = 1000;
|
|
// protected Type[] VerifyTypes { get; set; }
|
|
// //public HttpTryAttribute()
|
|
// //{
|
|
|
|
// //}
|
|
|
|
// public HttpTryAttribute(params Type[] verifyTypes)
|
|
// {
|
|
// VerifyTypes = (verifyTypes ?? new Type[0]);
|
|
// }
|
|
// public override Task Invoke(AspectContext context, AspectDelegate next)
|
|
// {
|
|
// var verify = HttpResultVerify.TryVerify(() =>
|
|
// {
|
|
// next(context).Wait();
|
|
// return (HttpResult)context.ReturnValue;
|
|
// }, MaxRetryTimes, RetryIntervalMilliseconds);
|
|
// if (VerifyTypes != null && VerifyTypes.Count() > 0)
|
|
// {
|
|
// foreach (Type item in VerifyTypes)
|
|
// {
|
|
// if (typeof(IHttpResultVerify).IsAssignableFrom(item))
|
|
// {
|
|
// verify.UseCheckResult((IHttpResultVerify)Activator.CreateInstance(item));
|
|
// }
|
|
// }
|
|
// }
|
|
// verify.Exec();
|
|
// return Task.FromResult(0);
|
|
// }
|
|
// }
|
|
//}
|