public void QueryObject(QueryExpression expression, IQueryResultInterest interest, object? @object) { var result = _storeDelegate.QueryObject(expression); if (result.StateObject != null) { interest.QueryObjectResultedIn(Success.Of <StorageException, Result>(Result.Success), result, @object); } else { interest.QueryObjectResultedIn(Failure.Of <StorageException, Result>(new StorageException(Result.NotFound, "No object identified by expression: " + expression)), QuerySingleResult.Of(null), @object); } }
public void QueryObjectResultedIn(IOutcome <StorageException, Result> outcome, QuerySingleResult result, object @object) { outcome .AndThen(good => good) .Otherwise(bad => throw new InvalidOperationException($"Bogus outcome: {bad.Message}")); _access.WriteUsing("add", result.StateObject); }
public void QueryObjectResultedIn(IOutcome <StorageException, Result> outcome, QuerySingleResult queryResult, object? @object) { outcome .AndThen(result => { OnStateObject((T)queryResult.StateObject !); DisperseStowedMessages(); return(result); }) .Otherwise(cause => { DisperseStowedMessages(); var ignoreNotFound = (bool)@object !; if (!ignoreNotFound) { var message = $"State not restored for: {GetType()}({Id}) because: {cause.Result} with: {cause.Message}"; Logger.Error(message, cause); throw new InvalidOperationException(message, cause); } return(cause.Result); }); }