public Option <CommandCompletion <TSpec> > Complete <TSpec>(CommandResult <TSpec> result) where TSpec : CommandSpec <TSpec>, new() { if (Dispatches.TryGetValue(result.SubmissionId, out ICommandDispatch dispatched)) { var completion = CommandCompletion.Create((CommandDispatch <TSpec>)dispatched, result, now()); if (!Completions.TryAdd(result.SubmissionId, completion)) { throw new Exception("Can't add task to the memory completion index"); } else { return(completion); } } return(none <CommandCompletion <TSpec> >()); }