| | | 1 | | using System.Collections.Generic; |
| | | 2 | | |
| | | 3 | | // Base implementation of a release strategy. |
| | | 4 | | public abstract class ReleaseStrategyBase : IReleaseStrategy { |
| | 0 | 5 | | public IAgent Agent { get; init; } |
| | | 6 | | |
| | 0 | 7 | | public ReleaseStrategyBase(IAgent agent) { |
| | 0 | 8 | | Agent = agent; |
| | 0 | 9 | | } |
| | | 10 | | |
| | | 11 | | // Release the sub-interceptors. |
| | 0 | 12 | | public List<IAgent> Release() { |
| | 0 | 13 | | if (Agent is not CarrierBase carrier || carrier.NumSubInterceptorsRemaining <= 0) { |
| | 0 | 14 | | return new List<IAgent>(); |
| | | 15 | | } |
| | | 16 | | |
| | 0 | 17 | | List<IHierarchical> leafHierarchicals = |
| | | 18 | | Agent.HierarchicalAgent.LeafHierarchicals(activeOnly: false, withTargetOnly: true); |
| | 0 | 19 | | return Release(leafHierarchicals); |
| | 0 | 20 | | } |
| | | 21 | | |
| | | 22 | | // Release the sub-interceptors for the given leaf hierarchical objects. |
| | | 23 | | protected abstract List<IAgent> Release(IEnumerable<IHierarchical> hierarchicals); |
| | | 24 | | } |