Relative Content


Merge collections without duplicates in C#

Your task is to merge two lists of objects. The resulting collection should be without duplicates, based on a certain property on the objects. The lists are populated with very simple Person objects. 1 2 3 4 5 class Person { public int Number { get; set; } public string Name { get; set; } […]


Code Complete, 2nd edition. It’s about the construction of software and the design that goes in the small parts of the code you write. The book is huge, so reading it might take a while, but it’s still very relevant and useful. The Clean series (Code, Coder, Architecture), those 3 books deal with different aspects of the […]

Replace switch statement with strategy pattern

using NLog; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Http; using System.Net.Http.Formatting; using System.Web.Http.Filters; using TaxMs.DTOs; using TaxMs.Infrastructure.CustomExceptions; using TaxMs.Infrastructure.Extensions; namespace TaxMs.ApiNet.Filters { public class AlertServiceFilter : ExceptionFilterAttribute { private readonly Logger _logger = LogManager.GetCurrentClassLogger(); public HttpStatusCode GetStatusCodeFromException(Exception exc) { if (exc is ArgumentException || exc is FileNotFoundException) return HttpStatusCode.BadRequest; if […]


IIS Routing

I was getting a 404 error when calling an apparently well configured Web API endpoint routing. I solved this issue by editing the node in web.config file adding this line: … …