internal void AddSubordinate(OperationBase subordinate) { var id = NextSubordinateID; if (!_subordinates.TryAdd(id, subordinate)) { throw new DnsServiceException(ServiceError.BadParam); } subordinate.SubordinateID = id; subordinate.Connection = this; }
public async Task AddAndExecuteSubordinate(OperationBase subordinate) { if (State != OperationState.Executing) { throw new InvalidOperationException($"ConnectionOperation is in the {State} state"); } AddSubordinate(subordinate); // subordinate will remove itself if it fails to execute await subordinate.ExecuteAsync(); }
internal bool IsSubordinate(OperationBase operation) { return(_subordinates.ContainsKey(operation.SubordinateID)); }
internal void RemoveSubordinate(OperationBase subordinate) { _subordinates.TryRemove(subordinate.SubordinateID, out subordinate); }