-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Problem
The current mechanism of Registration Visitor initialization uses an Initialize function on the IRegistrationVisitor interface. When further initialization was needed the IRegistrationVisitorEx interface was introduced.
What happens when even more initialization is required IRegistrationVisitorExEx
? It's got a bit of a code smell.
Proposal
Instead of using an Initialize method on the IRegistrationVisitor
interface, Registration Visitors should express their initialization requirements via constructor parameters (this is an IoC project after all). A very limited (TBD) set of potential objects can be specified.
The VisitorFactory should then be updated to reflect upon the discovered visitors, to dynamically generate a Factory function, but rather than generate Func<object>
, functions generate Func<PotentialArg1, PotentialArg2, object>
functions.
The dynamically generated expression tree will then use the appropriate argument on the constructor. See CodeCompilation.CreateContainerFactory for another example.
Steps
- Refactor the VisitorFactory to reflect visitor construct arguments
- Generate
Func<PotentialArg1, PotentialArg2, object>
factory functions - Update the various Registration Visitors to use constructor initializaton.
- Remove Initialize from IRegistrationVisitor and delete IRegistrationVisitorEx