Aethel.Extensions.Application 5.3.0

dotnet add package Aethel.Extensions.Application --version 5.3.0
NuGet\Install-Package Aethel.Extensions.Application -Version 5.3.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="5.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aethel.Extensions.Application --version 5.3.0
#r "nuget: Aethel.Extensions.Application, 5.3.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=5.3.0

// Install Aethel.Extensions.Application as a Cake Tool
#tool nuget:?package=Aethel.Extensions.Application&version=5.3.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 (2)

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

Package Downloads
Aethel.Framework.Atlantis

Domain Driven Design Framework for fast developtmen and easy extension

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 477 5/2/2022
5.2.0 2,108 4/29/2022
5.1.0 472 4/28/2022
5.0.0 512 4/26/2022
4.1.0 404 4/14/2022
4.0.0 390 4/14/2022
3.0.0 386 4/14/2022
2.3.1 418 4/12/2022
2.3.0 414 4/12/2022
2.2.0 411 4/12/2022
2.1.0 402 4/9/2022
2.0.0 400 4/9/2022
1.2.1 413 4/9/2022
1.2.0 404 4/9/2022
1.1.0 447 4/2/2022
1.0.1 430 3/10/2022
1.0.0 399 3/10/2022

Removiendo la interface de publisher y consumer