public async Task <bool> ExecuteAsync(CancellationToken token = default) { RentedCook = await _pool.RentAsync(CanExecute, null, token); if (token.IsCancellationRequested) { return(false); } Started?.Invoke(); var result = await ExecuteWithRentedCookAsync(token); if (RentedCook != null) { _pool.Return(RentedCook); } return(result); }
private bool CanExecute(Cook cook) { var currentState = _stateProvider.GetCurrentState(cook); return(!this.HasUnsatisfiedPreconditions(currentState)); }
public DomainState GetCurrentState(Cook cook) { return(DomainState.Empty.Set("isCarrying", cook?.CarriedIngredient ?? default)); }