How do you compare two similar JSON array set ? I bet that is a scenario you might have across atleast once in your developer life. Let us say you have following two sets of JSONs. Json Set 1 [ { "SourceLocation":"England", "DestinationLocation":"Spain", "DeliveryDate":"9/12" }, { "SourceLocation":"England", "DestinationLocation":"Germany", "DeliveryDate":"9/12" } ] Json Set 2 [ … Continue reading Compare JSON Arrays
Category: C#
The required modifier : Understand the limitations
C# 11 introduced the required modifier, which indicates that the applied peroperties and fields should be initialized by all available constructors or using object initializer. We learned more about the modifier in our earlier post. In this post, we take a look into a limitation of the functionality. Consider the following code. publicclassFoo { public required string Name {get;set;} public … Continue reading The required modifier : Understand the limitations
K-Sum – A generalized solution
In this blog post, we will attempt to address the 4-Sum problem from Leet code using the generic approach of K-Sum. Let us state the official definition of the problem. Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, … Continue reading K-Sum – A generalized solution
Mediator using MassTransit
In our previous blogs, we had visited the Mediator Pattern and also walked through the implementation of Mediator using Mediatr library. In this example, we will look into an alternative library - the MassTransit. Over the years, MassTransit has made its APIs a lot more simpler. I wasn't a huge of the earlier implementations, but the last time I … Continue reading Mediator using MassTransit
Generate Password Hash for RabbitMq
In the previous post, we explored how to use docker compose to per-initialize queues in a docker container. The configuration files also provided a way to initialize users. Each of the users where configured with a password, which is given in the configuration file as a hash value comprising of a randomly generated 32 bit salt and … Continue reading Generate Password Hash for RabbitMq
Circuit Breaker with Ocelot & Polly – Part 2
In the previous blog post on Circuit Breaker with Ocelot And Polly, we saw how we could use the Ocelot library's inbuilt support for Polly to build Circuit breakers for handling timeout errors from the downstream services. In this blog post, we will address, how we could trigger a circuit breaker when the downstream service returns … Continue reading Circuit Breaker with Ocelot & Polly – Part 2
Handling Cyclic References during Serialization
In the previous post, we discussed handling subtypes during protubuf serialization. In this post, we will continue with serialization and discuss the handling of cyclic references. We will look into how cyclic references could be addressed in 3 key types of serializations. JsonXmlProtobuf As an example of cyclic references, we will address the classic example … Continue reading Handling Cyclic References during Serialization
Implementing Mediator And CQRS in .Net 6 Web Api
In some of the previous posts, we visited the Mediator and CQRS patterns, understanding the benefits it brings to the table. In this blog post, we will look into implementing the Mediator and CQRS pattern in our .Net Core Web Api application. We would be using the Mediatr library by Jimmy Bogard for the implementation of the … Continue reading Implementing Mediator And CQRS in .Net 6 Web Api
A2Z.Net : B – BackgroundService
Long-running background processes have been a need for long and for over the years, this has been accomplished in various approaches in .Net. With the introduction of Worker Service templates, it has become a lot easier to create asynchronous long-running background tasks that are supported across platforms and have inbuilt capabilities like Dependency Injection. The … Continue reading A2Z.Net : B – BackgroundService
Why is ForEach Iteration over List<T> faster than IList<T>
In this post, I would like to draw your attention to the performance implications when iterating over IList<T> and List<T> . First let us begin by writing some code to run our benchmark tests against. We will execute a simple foreach loop against IList<T> and List<T>. [Benchmark] [ArgumentsSource(nameof(IListCollection))] public void ForEachIList(IList<int> collection) { foreach (var item in collection) { DoSomething(item); } } … Continue reading Why is ForEach Iteration over List<T> faster than IList<T>