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

How to trace log method calls, including the parameter values

I want to log method calls, including their parameter names and values, and what called the method. I want to minimize the amount of coding involved. For example: What options are available? Aspect-Oriented Programming (AOP) approach that proxies your method calls. It logs the method calls, and then calls your method. In .NET, you can … Read more How to trace log method calls, including the parameter values

C# – Using custom attributes

In this article I’ll be showing how to use custom attributes in C#. As an example, I’m creating a Console app that color codes output based on a status. Here’s what this looks like: What is an attribute? First of all, what is an attribute? Attributes are a clean way to add additional information about … Read more C# – Using custom attributes