My architecture service level consists of many single-purpose command classes (classes that perform one specific function for data, such as creating a user) and query classes (separate classes that query a database for specific data). They are injected into my Asp.net MVC controller classes through the Windsor installers.
For example, I run container.Register(Component.For<CreateUserCommand>().ImplementedBy<CreateUserCommand>());in my custom class IWindsorInstallerto instantiate CreateUserCommandin my controllers.
The problem is that since each class of the command / request is a single whole, I get a lot of these classes, and maintaining my installer class will be a pain in the butt. It occurred to me that this would be a great job for T4, since I can just start T4 and update the installer class to automatically register all my command and query classes.
Unfortunately, since I never did T4, before I do not know how to do it. I read the basics of T4, but my main point of confusion is how to actually find all my classes of commands and queries through T4.
On paper, I can find all of my command / query classes because they are defined in MyApp.DomainModel.Commands.*and namespaces MyApp.DomainModel.Queries.*. For example, a class CreateUserCommandis in a namespace MyApp.DomainModel.Queries.Users. However, I have no idea how to get around the actual lookup of namespaces at runtime, not to mention recursively.
Possible for me to create an interface ICommandand IQueryfor these classes, based on the fact, if it is easier to find in T4, than the namespace, but I do not know how to find all ICommand/IQuerysubclasses through T4.
I really know reflection, but from reading I read a lot, saying that using reflection in T4 is a bad idea and / or does not work properly.
If anyone could point me to anything that would help me accomplish this, I would be very grateful!