using System; using YLErp.Derivatives.Interest; namespace YLErp.Modules.SwapModule; /// /// SwapDealService 专用取价器:通过实例方法委托给 TryGetFloatRate(virtual), /// 而非 Fr007IndexFixer.Instance 那样直接调 EodPriceQueryService。 /// /// 为什么不用静态 Instance:SwapDealService.TryGetFloatRate 是 protected virtual, /// 测试通过 override 它注入 stub 利率。静态 Instance 绕过这个接缝会让 45 个测试失败。 /// 本类把 TryGetFloatRate 包成 IIndexFixer,既保留 virtual 接缝,又用上 IndexFixerBase。 /// internal sealed class SwapDealIndexFixer : IndexFixerBase, IIndexFixer { private readonly SwapDealService _owner; internal SwapDealIndexFixer(SwapDealService owner) => _owner = owner; public bool TryGetFixing(DateTime fixingDate, string underlyingCode, out decimal rate) { bool ok = _owner.TryGetFloatRate(fixingDate, underlyingCode, out double r); rate = Convert.ToDecimal(r); return ok; } }