public override bool ShouldIntercept(InterceptInfo e) { if (e.TypeName == LATE_BINDING && e.MethodName.StartsWith("Late")) { return true; } return false; }
private void OnInterceptExecuted(InterceptInfo input, Exception ex) { }
private async Task InterceptTrade(InterceptInfo info) { SuplierInfo supplier = info.supplier; string spu = info.spuId; TopTrade trade = info.trade; Statistic statistic = info.statistic; AppendText("将拦截订单{0},买家:{1}", trade.Tid, trade.BuyerNick); trade.Intercept = true; AppDatabase.db.TopTrades.Update(trade); var product = AppDatabase.db.ProductItems.FindById(trade.NumIid); try { if (!await this.SetProductProfit(product, (x) => 0, forceModify: true)) { statistic.InterceptFailed++; AppDatabase.db.Statistics.Upsert(statistic, statistic.Id); OnStatisticUpdate(statistic); } else { AppendText("商品{0}改价已提交", trade.NumIid); //1分钟后关单 await Task.Delay(1000 * 60 - 500); AppendText("{0}关闭交易...", trade.Tid); await CloseTradeIfPossible(trade.Tid); } } catch (Exception ex) { AppendException(ex); } }
public override bool ShouldIntercept (InterceptInfo info) { return info.TypeName.EndsWith("SomeTargetClass") && (info.MethodName.StartsWith("SomeMethod") || info.MethodName.EndsWith("ctor")) || info.MethodName == "MethodThatDoesNotExist"; }
public override bool ShouldIntercept(InterceptInfo info) { return info.TypeName.Contains(Find); }