//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 //{ // /// // /// Http请求请求失败重新尝试 HttpStatusCode 状态不为Ok一律重新尝试 // /// // [AttributeUsage(AttributeTargets.Method)] // public class HttpTryAttribute : AbstractInterceptorAttribute // { // /// // /// 最大尝试次数 // /// // public int MaxRetryTimes { get; set; } = 3; // /// // /// 重新尝试延迟时间毫秒 // /// // 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); // } // } //}