-
Book Overview & Buying
-
Table Of Contents
Metaprogramming in C#
By :
With the Types class, we now have a raw approach to get all the types in a running system. This can be very helpful on its own as you can now use this to perform Language Integrated Query (LINQ) queries on top of finding types that match specific criteria you’d be interested in.
A very common scenario in code in general is that we have base classes or interfaces that represent characteristics of known artifact types in our system and we create specialized versions that override virtual or abstract methods, or just implement a specific interface to represent what it is. This is the power of object-oriented programming languages.
With this, we are adding additional implicit metadata into our systems that we can leverage. For instance, in Chapter 3, Demystifying through Existing Real-World Examples, we looked at how ASP.NET does this by discovering all classes that have Controller as their base type.
From my own experience, this is the typical pattern...