Tutorials

Tutorials

Catalog of C# Structural Patterns

Catalog of C# Structural Patterns

Catalog of C# Structural Patterns

Adapter: is a structural design pattern that allows objects with incompatible interfaces to collaborate.

Bridge: is a structural design pattern that lets you split a large class or a set of closely related classes into two separate hierarchies—abstraction and implementation—which can be developed independently of each other.

Composite: is a structural design pattern that lets you compose objects into tree structures and then work with these structures as if they were individual objects.

Decorator: is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.

Facade: is a structural design pattern that provides a simplified interface to a library, a framework, or any other complex set of classes.

Flyweight: is a structural design pattern that lets you fit more objects into the available amount of RAM by sharing common parts of state between multiple objects instead of keeping all of the data in each object.

Proxy: is a structural design pattern that lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.

Web site reference: https://refactoring.guru

Read More

Catalog of C# Creational Patterns

Catalog of C# Creational Patterns

Catalog of C# Creational Patterns

Abstract Factory: is a creational design pattern that lets you produce families of related objects without specifying their concrete classes.

Builder: is a creational design pattern that lets you construct complex objects step by step. The pattern allows you to produce different types and representations of an object using the same construction code.

Factory Method: is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.

Prototype: is a creational design pattern that lets you copy existing objects without making your code dependent on their classes.

Singleton: is a creational design pattern that lets you ensure that a class has only one instance, while providing a global access point to this instance.

Web site reference: https://refactoring.guru

Read More

Parte 5 – Agregar Swagger a GestaProject.WebAPI

Parte 5 – Agregar Swagger a GestaProject.WebAPI

 

 

 

 

 

 

 

Parte​​ 5​​ ​​ Agregar Swagger a GestaProject.WebAPI.

 

En el proyecto de GestaProject.WebAPI, necesitamos agregar algunas librerías y hacer unas pocas configuraciones en el código.

 

Swashbuckle.AspNetCore​​ ver. 4.0.1

Swashbuckle.AspNetCore.Swagger​​ ver. 4.0.1

Swashbuckle.AspNetCore.SwaggerGen​​ ver. 4.0.1

Swashbuckle.AspNetCore.SwaggerUI​​ ver. 4.0.1

 

Parar instalar esos paquetes, damos click derecho en el projecto GestaProject.WebAPI y seleccionamos Management Nuget Packages.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Buscamos los paquetes y los instalamos.

 

Nota: es muy importante que instales la versión 4.0.1

 

Ahora tenemos que editar el archivo Startup.cs del proyecto.​​ 

 

En​​ ConfigureServices, agregamos las siguientes líneas:

 

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)

                .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

​​ 

            services.AddSwaggerGen(options =>

            {

                options.SwaggerDoc("v1"new Swashbuckle.AspNetCore.Swagger.Info { Title = "GestaProject Web API", Version = "v1" });

            });

 

 

 

 

 

 

En​​ Configure​​ agregamos las siguientes líneas:

 

app.UseSwagger();

​​ 

            app.UseSwaggerUI(c =>

            {

                c.SwaggerEndpoint("/swagger/v1/swagger.json""GestaProject Web API v1");

            });

 

Quedando algo así:

 

 

 

En​​ ValuesController, haremos un cambio:

 

 

 

 

 

Y por​​ último​​ cambiamos la opción de Lanch browser del proyecto.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Y si todo, les sale bien, ejecutan la solución y verán la siguiente vista.

 

Read More