That's one pupose of IoC. But there may be other ways. Is this an ASP.Net or MVC app?
>In our vertical market VFP app, we use a data-driven abstract factory to instantiate all of our classes containing business logic. Basically, that means instead of using CreateObject("MyClass"), we use Factory("MyClassKey"). The factory looks up the class in a table, then instantiates and returns the object. An important benefit of the factory is that it allows us to substitute a custom class for the standard one. For example, if a client wants us to customize a calculation for them, we put it in a custom class, install it on their system, then use the factory to instantiate the custom class in place of the standard one.
>
>I'm wanting to implement something similar in C#. The customizations for a specific client would be compiled into a custom DLL. Then I need to instantiate the custom class in place of the standard one. I figure I could probably roll my own factory using reflection and whatnot. I wondered if there was already a standard solution to this problem. I've been learning about IoC containers, but I can't tell if they do what I need. I'm not sure I buy into all of the dependency injection stuff, but I would be willing to use an IoC container if it also met my need with customizations. Or maybe there is some other mechanism built into .NET to achieve what I need. Any suggestions?
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer