.NET / C#
I love programming in .NET / C#. Have been doing it since 2004 now. Much has changed since: the .Net framework is got more libraries, NuGet was a game-changer and even C# itself is evolving with lambda and dynamic.
And now .Net has evolved to Standard and Core with support for other platforms like Linux / Docker. Things are getting easier and faster.
Prometheus Latency Metrics & Exception Logging with Scrutor Decorators
Ever since I stumbled upon the Scrutor project, I wanted to write a blog about building latency and exception logging decorators. At Wehkamp we used StructureMap in the past, but as it became obsolete and swapped out, I missed the decorators. What I love about…
Dependency Injection based on request headers
Dependency Injection (DI) helps us to change the behavior of parts of our program on the fly. This is especially neat when you want to test your domain services against a mocked data-store. But what if you need to change the behavior of your API based on a request header?
Yesterday I had a discussion with my colleague Robert Kranenburg about this. He showed an example of a console application changing its behavior based on an argument. I took the idea and converted it into .NET Core 3.1 code to change behavior based on a cookie.
“Is One Of” and “Is Not One Of” validation attributes
I love attribute validation! They can be used for a myriad of things. In .NET Core MVC we use them to validate models that come into our controllers. In one of our projects we kept running into the same thing: we need to validate a value against an array of pre-defined values. So we wrote some base validation attributes.
Validate strongly typed options when using config sections
I like to validate my application configuration upon startup. Especially when doing local development, I want to know which application settings are missing. I also like to know where I should add them. This blog shows how to implement validation of your configuration classes using data annotations.
Connect to Jira with a Private Key (OAuth) using .NET
We have a .NET service that needs to connect with Jira to create, update and read issues. It would be easy if we could use a username & password for authentication, but for this integration we need to implement the connection to Jira with a Private Key. All requests have to be signed with OAuth.
Building a high performing last viewed list using Redis
We live in a day and age in which we can choose a data-store that matches the characteristics of our apps and (micro) services. Lately we’ve been looking into Redis as a high performing store for last viewed items. In this blog I’ll look show how to create a POC with the redis-cli and then implement it using .NET Core. We’ll be using the sorted set structure.
Dictionary-style settings as IOptions
I love how we can use appsettings.json files to configure applications in the .NET Core platform. The JSON-format feels a lot less bloated than the old XML appSettings config I used to work with. In this blog I’ll explore how to load a dictionary-style settings class as an IOption. This can be very useful when working with dependency injection.
Setup multiple appsetting-files with a .NET Console Application
In ASP.NET Core we are used to have multiple appsettings.json files with settings that differ per environment. I want to do the same in a Console Application. This makes debugging the application easier.
Sorting a Dictionary on a List of Keys
I can almost hear you thinking: “What super-weird problem are you trying to solve!?” Well… it is kind of an abstract one! Imagine you have a dictionary of objects and a separate list of keys in a certain order. Now suppose you want an ordered dictionary based on the list of keys.
Dependency injection (with IOptions) in Console Apps in .NET Core
When you are used to building web applications, you kind of get hooked to the ease of Dependency Injection (DI) and the way settings can be specified in a JSON file and accessed through DI (IOptions