As we discussed in earlier posts, the Mediator and Command are patterns that can be implemented in different way. And those patterns already exist in many coding frameworks. As a matter of fact, the ASP.NET WebApi request pipeline can be considered a Mediator and Command implementation, especially when building MinimalApi. Remember that a Mediator encapsulates … Continue reading Is ASP.NET WebApi Pipeline Already a Mediator?
Category: .NET
Getting Started with D20Tek.Mediator Package
There are a few Mediator and Command implementations in the .NET ecosystem. The most popular one has been Mediatr. But with the recent announcement that Mediatr is moving to a commercial license, many developers looking for alternatives. In an attempt to support the .NET community, I am building a simplified Mediator and Command library that … Continue reading Getting Started with D20Tek.Mediator Package
Using the with Expression on Classes
Just today I learned that the with expression in C# is not limited to records. It can also be used with classes, as long as the class is defined with the with expression requirements. And what are the requirements to work with the with expression? Requirements for with expressions to work: The type must be … Continue reading Using the with Expression on Classes
Setting up WebApi Sample Project
In many of our future articles, we will be using ASP.NET MinimalApi project to show how the Mediator library can be used. So in this article, we will discuss how to create WebApi projects in Visual Studio. Create the WebApi Project If you don't already have a WebApi project, please create a new one called … Continue reading Setting up WebApi Sample Project
Understanding the Mediator and Command Patterns: Theory, Use Cases, and Trade-offs
In the world of software design, decoupling is a recurring goal. Systems built from loosely coupled components are more maintainable, testable, and scalable. But we still want to balance that with being easy to use in simple scenarios. Two design patterns that often work well together to achieve this are the Mediator and Command patterns. … Continue reading Understanding the Mediator and Command Patterns: Theory, Use Cases, and Trade-offs
Central Package Management with NuGet
Managing dependencies across multiple projects can get unwieldy, especially as the project count grows. NuGet's Central Package Management (CPM) feature aims to simplify this by letting developers define package versions in a single location. With CPM, you avoid the redundancy of specifying package versions in each project individually. Here, we’ll explore how to set up … Continue reading Central Package Management with NuGet
Secure Minimal APIs with API Key Authentication
If you’re building a .NET 8 application and want robust security, you might assume it requires a lot of complex authentication setup. But here’s the good news: you can implement API key authentication with just a few lines of code. With this straightforward approach, you can secure your services against unauthorized access quickly and easily. … Continue reading Secure Minimal APIs with API Key Authentication
Understanding await vs. ContinueWith in C# Async Programming
When it comes to asynchronous programming in C#, developers have powerful tools to make applications more responsive and efficient. By allowing long-running operations to execute in the background, we can keep the UI thread free for other tasks, resulting in smoother user experiences. Or when running those tasks on ASP.NET, the service can respond to … Continue reading Understanding await vs. ContinueWith in C# Async Programming
How to Make Internal Types Visible to Other Projects Using .csproj File
In many software development scenarios, especially when working with unit tests, you might encounter situations where you need to test internal types and methods within your code. However, internal members are, by default, inaccessible to other projects. The traditional approach to solving this problem in .NET is to make these internal types visible to specific … Continue reading How to Make Internal Types Visible to Other Projects Using .csproj File
Currency Input in Spectre.Console
I was trying this just the other day in Spectre.Console. I wanted an input prompt that would accept currency values. I started down the path of using a decimal representation (TextPrompt<decimal>). While that mostly worked on the input value, it does not support using negative sign, separators, or decimal places. I wanted to be able … Continue reading Currency Input in Spectre.Console