-
Notifications
You must be signed in to change notification settings - Fork 0
Home
to get started using the library you can install it from the NuGet package manager Install-Package YoussefSell.Result.Net
Result.Net is a library that exposes a Result object that allows you to encapsulate the execution status of an operation so that instead of throwing exceptions you return a result object that describes the status of the execution, this is a common pattern you may want to read this article "To Throw or To Return (Exceptions vs Result Object)?" for more details on when to use the Result Object pattern over exception and when not.
there are three types of the Result objects
- Result: this type is used to describe the execution status of a void method with no return value.
- Result: this type is a generic type that drives from Result, and is used to describe the execution status of a method with a return value.
- ListResult: same as Result but it used if the TData is list, so that instead of using Result<IEnumerable> we use ListResult, which is internal driving from Result<IReadOnlyCollection>.
for more details on each Result object type, check out the Result Object Page.
when you will use the Result object you are not going to instantiate the object directly using the new keyword (which you can by the way), but you will utilize one of the static methods on the Result type to create your instance.
to create a successful result use Result.Success(), and to create a failure result use Result.Failure().
for more details on the available method check the helper methods page.