diff --git a/CSharpFunctionalExtensions/Result/Methods/FailureAsync.cs b/CSharpFunctionalExtensions/Result/Methods/FailureAsync.cs new file mode 100644 index 00000000..aebfd7fc --- /dev/null +++ b/CSharpFunctionalExtensions/Result/Methods/FailureAsync.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; + +namespace CSharpFunctionalExtensions +{ + public partial struct Result + { + /// + /// Creates a failure async result with the given error message. + /// + public static Task FailureAsync(string error) + { + return new Task(() => Failure(error)); + } + + /// + /// Creates a failure async result with the given error message. + /// + public static Task> FailureAsync(string error) + { + return new Task>(() => Failure(error)); + } + + /// + /// Creates a failure async result with the given error. + /// + public static Task> FailureAsync(E error) + { + return new Task>(() => Failure(error)); + } + } +} diff --git a/CSharpFunctionalExtensions/Result/Methods/SuccessAsync.cs b/CSharpFunctionalExtensions/Result/Methods/SuccessAsync.cs new file mode 100644 index 00000000..0859c706 --- /dev/null +++ b/CSharpFunctionalExtensions/Result/Methods/SuccessAsync.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; + +namespace CSharpFunctionalExtensions +{ + public partial struct Result + { + /// + /// Creates a success async result. + /// + public static Task SuccessAsync() + { + return new Task(() => Success()); + } + + /// + /// Creates a success async result containing the given value. + /// + public static Task> SuccessAsync(T value) + { + return new Task>(() => Success(value)); + } + + /// + /// Creates a success async result containing the given value. + /// + public static Task> SuccessAsync(T value) + { + return new Task>(() => Success(value)); + } + } +}