C# – Load all types that implement an interface in the current assembly

To get all types in the current assembly that implement a specified interface, use the following: To create instances of these types, loop through them and use Activator.CreateInstance(), like so: Example – Auto-wire a command routing table Let’s say we want to build a command routing table. We have commands and want to automatically wire … Read more C# – Load all types that implement an interface in the current assembly

C# – Generic Plugin Loader

This article explains how to create a generic plugin loader that solves many real world problems when loading plugins in .NET. Besides being generic, this plugin loader also solves the following real world problems when working with plugins: Loads assemblies that have dependencies. Load assemblies that have unmanaged dependencies (like C++ DLLs). Solves the “IsAssignableFrom … Read more C# – Generic Plugin Loader

Multithreaded quicksort in C#

One day I decided to challenge myself by trying to implement multithreaded quicksort. I wanted to see how it would compare to the built-in sort function – Array.Sort(). I came up with two algorithms that were 2-4x faster than Array.Sort(): Top-down: divide-fork-sort-merge Bottom-up: quicksort with fork-on-recursion After continuing to tinker, in attempts to further optimize, … Read more Multithreaded quicksort in C#