csharp4405de34 | 1 | namespace CascadeIDE.Cockpit.DataBus; |
| 2 | |
| 3 | /// <summary> |
| 4 | /// Как маршрутизировать <see cref="TEvent"/> в async-режиме <see cref="InMemoryDataBus"/>: |
| 5 | /// <see cref="IsBurst"/> → bounded(1) + DropOldest, иначе unbounded. |
| 6 | /// </summary> |
| 7 | public readonly struct DataBusEventPolicy |
| 8 | { |
| 9 | private readonly IReadOnlyDictionary<string, bool>? _burstByTypeName; |
| 10 | |
| 11 | /// <param name="burstByTypeName">Ключ — <see cref="Type.Name"/> типа события; значение true = burst.</param> |
| 12 | public DataBusEventPolicy(IReadOnlyDictionary<string, bool> burstByTypeName) |
| 13 | { |
| 14 | ArgumentNullException.ThrowIfNull(burstByTypeName); |
| 15 | _burstByTypeName = burstByTypeName; |
| 16 | } |
| 17 | |
| 18 | public bool IsBurst(Type eventType) => |
| 19 | _burstByTypeName?.GetValueOrDefault(eventType.Name, defaultValue: false) == true; |
| 20 | } |
| 21 | |
View only · write via MCP/CIDE