AsContinuation
Transforma um valor TSuccess ou TFail em um Continuation<TFail, TSuccess>.
| Parâmetros | Retorno |
|---|---|
|
TSuccess value |
Continuation<TFail, TSuccess> |
|
TFail value |
Continuation<TFail, TSuccess> |
Como Usar
Este método comumente é utilizado para iniciar um novo pipeline de Continuation nos estados Success ou Fail.
Quando o valor é um TSuccess
string result = 10.AsContinuation<string, int>()
.Then(value => value + 10)
.Catch(fail => $"Error: {fail}")
.Match(number => number.ToString(),
error => error);
//result = "20"
Quando o valor é um TFail
string result = "test".AsContinuation<string, int>()
.Then(value => value + 10)
.Catch(fail => $"Error: {fail}")
.Match(number => number.ToString(),
error => error);
//result = "Error: test"