Skip to main content

Posts

ASP.NET Core – Middleware

  ASP.NET Core – Middleware   A middleware is nothing but a component (class) which is executed on every request in ASP.NET Core application. There will be multiple middleware in ASP.NET Core web application. 1.     Configure Single middleware. 2.     Configure Multiple middleware. 3.     Configure Own custom middleware. 4.     We can set the order of middleware execution in the request pipeline.     The following figure illustrates the ASP.NET Core request pipeline processing.   Configure Middleware   We can configure middleware in the  Configure  method of the Startup class using  IApplicationBuilder  instance   public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error");   // Middlewear – (1) in Pipeline } ...
Recent posts

Liskov Substitution Principle

Liskov Substitution Principle We will be discussing the Liskov Substitution Principle also known as LSP, as one of the SOLID principles of object-oriented programming and how to implement it when designing our software. This principle said that Subtypes must be substitutable for their base types. In other words, if we substitute a superclass object reference with an object of any of its subclasses, the program should not break. Example Here we design three classes for employees and one abstract class and Implement abstract class on these classes, PermamentEmployee.cs ContractEmployee.cs TemporaryEmployee.cs class LSP { public LSP ( ) { Run ( ) ; } public void Run ( ) { Console . ReadLine ( ) ; } public abstract class Employee { protected string FullName { get ; set ; } protected abstract string CalculateBonus ( ) ; } public class PermamentEmployee : Employee ...

Open Closed Principle

  Open Closed Principle We will be discussing the Open-Closed Principle also known as OCP, as one of the SOLID principles of object-oriented programming and how to implement it when designing our software. This principle said that should be open for extension but closed for modification. We should write a code that does not require modification every time a customer changes its request. Example Let us define a class that contains salary calculations. Let us imagine that we have a task where we need to calculate the total cost of all the developer salaries in a single company. To get started, we are going to create the model class first, public class EmployeeReport { public int Id { get ; set ; } public string Name { get ; set ; } public string Level { get ; set ; } public int WorkingHours { get ; set ; } public double HourlyRate { get ; ...