This repository containers a lot of code samples for articles on my blog. It is easier to keep the code up to date when all of the items are grouped.
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<T>
). It's only logical to
want the same features in your Console app.
- 1.dependency-injection-with-ioptions-in-console-apps
- Dependency injection (with IOptions) in Console Apps in .NET
Services can use their private key to communicate with our service. We can configure the access for each issuer using standard .NET claims.
- 2.simple-jwt-access-policies-for-api-security-in-net
- Simple JWT Access Policies for API security in .NET
Options themselves can be collections as well. This
project shows how to use a Dictionary<string, string>
and a
List<string>
as base classes for options. Both are supported
by default.
How to use System.CommandLine
to build a CLI with commands and
dependency injection.
Parsing Roman Numerals in C# is a good way to explore (implicit) operator overloading.
I ❤️ Handlebars! So I was very very very happy to see that Handlebars was ported to .NET! It is a mega flexible templating engine as it can easily be extended. I'm working on a project where I need to parse objects via JSON templates to JSON strings. This blog will show how to instruct Handlebars to parse into JSON and add some nice error messages if your template fails.
Looks like my organization wants to manage my background picture. But I'm a local admin, so let's see if we can still change that background picture. When I go to Setting > Personalization > Background, I see the message: "Some of these settings are managed by your organization." If you are an admin, you might be able to (temporarily) override the wallpaper, by editing your registry and triggering a refresh of the wallpaper. If you can, you can automate it using PowerShell.
My new years resolution for 2025 is not to write a custom implementation if I have an Open API specification availabe. Let's use Kiota to generate a client and add resilience with the Microsoft Microsoft.Extensions.Resilience package (which is basically a wrapper around Polly).