The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral
stw wrote: I'd like to create an abstract factory that is configurable (a.k.a. runtime extenable). I want to call it with a parameter, that is matched against an configuration file to return an instance of a specific class (all classes inherit from a baseclass and this is what the factory returns. So I have Public Function EasterEggFactory(Eggtype as String) as EasterEgg Select Case Eggtype Case "red" Return new EggRed Case "blue" Return new EggBlue Case else Return new Egg End Select End Function The possible Classes are Hardcoded. However I'd like to read them from a configuration. (How to get them into a hasttable is the easy part). So my code should look like Dim classname as String = LookupClassName(EggType) if classname.Equals("") then classname = "Egg" end if Return new Who helps? :-) stw
Cyrus Crypt wrote:However, I have always heard about overhead of Reflection. Anyone can care to comment on their experiences on this?
You might want to visit this link to see what methods are considered lightweight and heavyweight in the Reflection namespace http://msdn.microsoft.com/msdnmag/issues/05/07/Reflection/default.aspx
It can be achieved easily through the use of DI container. Take a look at this.
http://sgdotnet.org/forums/permalink/204591/205374/ShowThread.aspx#205374
http://devpinoy.org/blogs/cruizer