Aethel.Extensions.Application 3.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Aethel.Extensions.Application --version 3.0.0                
NuGet\Install-Package Aethel.Extensions.Application -Version 3.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aethel.Extensions.Application" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aethel.Extensions.Application --version 3.0.0                
#r "nuget: Aethel.Extensions.Application, 3.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Aethel.Extensions.Application as a Cake Addin
#addin nuget:?package=Aethel.Extensions.Application&version=3.0.0

// Install Aethel.Extensions.Application as a Cake Tool
#tool nuget:?package=Aethel.Extensions.Application&version=3.0.0                

Aethel Extensions Application

Archivos de apoyo para la capa de aplicacion.

Componentes principales

Either

Estrcutura que nos permite devolver dos respuestas de una operacion. La primera es la respuesta esperada que se devolveria normalmente. La segunda opcion es un objeto de tipo Error que que define algunas propiedades basicas para comunicar la razon de fallo de la operacion. La idea detras de esta implementacion es evitar el flujo del sistema a traves de las excepciones

Uso:

public class SomeClass {
   // Propiedades
   // Metodos 
   public Either<SuccessResponse, Error> DoSomething(SomeRequest request){
       // Validaciones
       return new Error("5000","Something is wrong")
       // Regla de negocios
       return new SuccessResponse
   }
} 

Al implementar esta libreria ahora podemos manejar nuestra respuesta de la siguiente manera:


public IActionResult Post(SomeRequest request){
    return someClass.DoSomething(request)
        .Match( 
            success => StatusCode(200, "All good"),
            fail => StatusCode(400, "Not all good")
        );
}

De esta forma podemos realizar operaciones mas intuitivas y manejar de forma mas limpia y sin las cargas de las excepciones guiando nuestro codigo

Answer

La estructura de answer es la evolucion de either para permitir realizar las mismas operaciones con menos codigo. A diferencia de Either, Answer infiera y establece desde el inicio que el tipo de objeto para el fallo, sera un objeto de tipo Error, contenido dentro del ensamblado, asi con esto, solo tenemos que hacer lo siguiente para utilizarlo

public class SomeClass {
   // Propiedades
   // Metodos 
   public Answer<SuccessResponse> DoSomething(SomeRequest request){
       // Validaciones
       return new Error("5000","Something is wrong")
       // Regla de negocios
       return new SuccessResponse
   }
} 

Con esto, nuestro codigo se ve mas compacto y seguimmos siendo explicitos pues siemmpre regresaremos un error. Para consumirlo desde el llamador, seguimmos haciendo lo mismo


public IActionResult Post(SomeRequest request){
    return someClass.DoSomething(request)
        .Match( 
            success => StatusCode(200, "All good"),
            fail => StatusCode(400, "Not all good")
        );
}

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aethel.Extensions.Application:

Package Downloads
Aethel.Services.Kairos

Easy mechanism for reactive system

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.3.0 519 5/2/2022
5.2.0 2,142 4/29/2022
5.1.0 502 4/28/2022
5.0.0 542 4/26/2022
4.1.0 431 4/14/2022
4.0.0 417 4/14/2022
3.0.0 414 4/14/2022
2.3.1 448 4/12/2022
2.3.0 440 4/12/2022
2.2.0 440 4/12/2022
2.1.0 429 4/9/2022
2.0.0 428 4/9/2022
1.2.1 440 4/9/2022
1.2.0 433 4/9/2022
1.1.0 475 4/2/2022
1.0.1 464 3/10/2022
1.0.0 433 3/10/2022

Se  agrega la clase base para contener a todos los eventos de integracion