IOptions<T> gives us compile-time safety and eliminates magic strings.
Simple example below :
Click on the image for a larger view in a new window.
Code for the sample above as well as the IConfiguration alternative is available on my GitHub Gist.
You might also be interested in...
Simple string concatenation using String.Create and other performance sensitive approaches in .NET 8I posted my previous simple string concatenation benchmark results where I was concatenating my name with spacer on Reddit recently. … Continue reading Simple string concatenation using String.Create and other...
String.Equals with OrdinalIgnoreCase faster in .NET 8 compared with .NET 7
There’s some awesome string comparison OrdinalIgnoreCase improvements coming in .NET 8, although I did see one regression too. Click on … Continue reading String.Equals with OrdinalIgnoreCase faster in .NET 8...
Regular Expressions using RegexOptions.IgnoreCase slower than inline case insensitive pattern syntax in .NET 6
RegexOptions.IgnoreCase often offers better readability and expression of intent than inline pattern matching. We can see examples of the two … Continue reading Regular Expressions using RegexOptions.IgnoreCase slower than inline...
eShopOnWeb Architecture (9/16) – uses the Aggregate root pattern to ensure child objects are not manipulated out of context
Aggregate roots are a central concept in Domain Driven Design. The idea is pretty simple and refers to how certain entities … Continue reading eShopOnWeb Architecture (9/16) – uses the Aggregate...
C#9 new AND, OR, NOT pattern matching keywords
C#9 (released Nov 2020) has some pattern matching enhancements. Added in C#9 (among other pattern changes) is conjunctive patterns (AND … Continue reading C#9 new AND, OR, NOT pattern matching...