Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

I have a Factory class that creates number of classes to handle different XML responses, returned by Web Service. All of them are derived from some base class GwsResponse and created depending on the top name element name.
Previously factory and all created object classes were located in the same DLL.
Now we need to increase number of handled responses, but we want new classes to create in separate extension DLL. 

We are going to use Activator.CreateInstance to dynamically load the concrete class and avoid Circular references

The names of classes and assembly will be defined in config file.

The approach is well described in the thread:    

Circular references not possible?

Similar idea suggested in Creating an object dynamically using Reflection and running in a seperate thread

 

Links about Dependency Injection (pointed by TheCPUWizard)

Design Patterns Dependency Injection(MSDN Magazine, September 2005)

Unity competitors discussin on forum and post Microsoft releases Unity, an IoC library

 
 
Posted on Monday, May 5, 2008 11:36 PM .Net Framework | Back to top


Comments on this post: use Activator.CreateInstance to dynamically load the concrete class and avoid Circular references

# re: use Activator.CreateInstance to dynamically load the concrete class and avoid Circular references
Requesting Gravatar...
That is one approach, but with a potential for a performance hit (please note the word potential)...

A more "modern" approach is to use Dependancy Injection. Alas, I do not have a link handy, but this was covered in depth in MSDN magazine about 2-3 months ago.

One big plus....there are already libraries that provide sophisticated implementation!
Left by TheCPUWizard on May 07, 2008 1:26 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net