Resolve Open Generics with ASP.NET Cores DI-Container

ASP .NET Core already has quite a decent di-container built in. However, there are some quirks you might need to be aware of. In one of my applications, I’ve been using a factory pattern to register my views by using open generics. To be more clear about that: I have an Interface IView<TView>, and I want to register all of this interfaces implementations. As I found out, Microsofts DI-Container currently doesn’t support that by default (text me if I’m wrong!), but there’s a solution for this problem. Scrutor is a package that adds more complex di-features - specifically scanning. This means that, using this library, you now have the ability to scan through your assemblies and perform registrations based on your findings. ...

November 10, 2020 · 2 min · Marcel Jurtz

C# – Mastering the Basics - Extension Methods

In this series, I go over the very basics of the C# programming language. In todays guide, I will focus on writing custom extension methods for existing, prebuilt classes. You can use extension methods to add custom functionality to classes that are built by others. In my very case, I’d like to extend the functionality of the String class to set its first letter to upper case. I already implemented this functionality in my sideproject CryptoFolio, be sure to check out my article on the topic! ...

December 22, 2017 · 2 min · Marcel Jurtz

C# – Mastering the Basics – Collections

Altough the topic “Collections” matches programming in general, I’ve decided to add it to my series on mastering the basics of C#. For this reason, you will find some content here that is generally applicable, but I will also discuss different language-specific elements. Collections support several different use cases, e. g. searching through a set for objects with certain properties, or iterating through multiple elements by predefined sorting specifications. In the first part of this article, I will cover the two basic types of collections in C#, lists and dictionaries. Then, I will go over the groups of collections you might know from Java: lists, sets and maps. I’d like to describe and compare their characteristics and then implement their functionality in C#. ...

December 19, 2017 · 5 min · Marcel Jurtz

Getting Started with .NET Core on Arch Linux

Hello Internet! Today, we will try to develop and run .NET Core Apps on a Macbook running Arch Linux! Because what could go wrong! (Honestly, this went way better than I thought.) Installation Before we can start writing .NET Core applications on Linux, we need to install some packages. The Arch Wiki states that to run .NET Core applications, the dotnet-runtime package needs to be installed. Additionally, we will need dotnet-sdk-2.0 from the AUR to be able to develop custom applications. ...

December 16, 2017 · 3 min · Marcel Jurtz