Click here to Skip to main content
16,005,080 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to use the microsoft.directx namespace Pin
Dave Kreskowiak6-Jan-06 3:12
mveDave Kreskowiak6-Jan-06 3:12 
QuestionRemoving TiltleBar Pin
A.Grover5-Jan-06 23:17
A.Grover5-Jan-06 23:17 
AnswerRe: Removing TiltleBar Pin
AB77715-Jan-06 23:43
AB77715-Jan-06 23:43 
QuestionGet derived classes of a base class Pin
nmhuy5-Jan-06 22:02
nmhuy5-Jan-06 22:02 
AnswerRe: Get derived classes of a base class Pin
J4amieC5-Jan-06 22:16
J4amieC5-Jan-06 22:16 
GeneralRe: Get derived classes of a base class Pin
nmhuy5-Jan-06 23:47
nmhuy5-Jan-06 23:47 
AnswerRe: Get derived classes of a base class Pin
S. Senthil Kumar6-Jan-06 3:25
S. Senthil Kumar6-Jan-06 3:25 
GeneralRe: Get derived classes of a base class Pin
nmhuy6-Jan-06 8:19
nmhuy6-Jan-06 8:19 
Hi,

Here is the context that I use reflection:

- The library has a base class, e.g AbstractAlgorithm, and some derived classes, e.g ConcreteAlgorithm1, ConcreteAlgorithm2, ... We can get an algorithm instance like this: AbstractAlgorithm algo = new ConcreateAlgorithm1();

- I want to provide another way for client to get an algorithm instance by its name like this: AbstractAlgorithm algo = AlgorithmFactory.createInstance("XYZ algorithm");

So I add an abstract method "getName()" to AbstractAlgorithm base class and each concreate algorithm class implements this method to return its name. The "createInstance(string)" method of AlgorithmFactory will use reflection to enumerate through the derived classes of AbstractAlgorithm, call their "getName()" methods to select the right algorithm class. After that, I use .NET class Activator to create an algorithm instance of the selected class. By doing this (instead of using "switch case" statement), the "createInstance(string)" method is unchanged when new concrete algorithm classes are added to the library.

Is it a right design?
Hope to see your opinion.

Lan hue sau ai lan hue heo
Lan hue sau doi trong heo ngoai tuoi
GeneralRe: Get derived classes of a base class Pin
S. Senthil Kumar6-Jan-06 8:49
S. Senthil Kumar6-Jan-06 8:49 
GeneralRe: Get derived classes of a base class Pin
nmhuy6-Jan-06 9:16
nmhuy6-Jan-06 9:16 
GeneralRe: Get derived classes of a base class Pin
S. Senthil Kumar6-Jan-06 20:10
S. Senthil Kumar6-Jan-06 20:10 
GeneralRe: Get derived classes of a base class Pin
nmhuy6-Jan-06 22:53
nmhuy6-Jan-06 22:53 
Questionneed C# codes pls.... Pin
knight_sky5-Jan-06 18:45
knight_sky5-Jan-06 18:45 
AnswerRe: need C# codes pls.... Pin
Colin Angus Mackay5-Jan-06 20:59
Colin Angus Mackay5-Jan-06 20:59 
AnswerRe: need C# codes pls.... Pin
Ravi Bhavnani6-Jan-06 1:52
professionalRavi Bhavnani6-Jan-06 1:52 
AnswerRe: need C# codes pls.... Pin
TheGreatAndPowerfulOz6-Jan-06 7:34
TheGreatAndPowerfulOz6-Jan-06 7:34 
GeneralRe: need C# codes pls.... Pin
aerosmith2k18-Jan-06 7:06
aerosmith2k18-Jan-06 7:06 
GeneralRe: need C# codes pls.... Pin
TheGreatAndPowerfulOz8-Jan-06 11:52
TheGreatAndPowerfulOz8-Jan-06 11:52 
Questionneed help!!! i'm desperate Pin
knight_sky5-Jan-06 18:38
knight_sky5-Jan-06 18:38 
AnswerRe: need help!!! i'm desperate Pin
leppie5-Jan-06 20:26
leppie5-Jan-06 20:26 
AnswerRe: need help!!! i'm desperate Pin
Colin Angus Mackay5-Jan-06 20:52
Colin Angus Mackay5-Jan-06 20:52 
AnswerRe: need help!!! i'm desperate Pin
BruceN7-Jan-06 2:14
BruceN7-Jan-06 2:14 
Questionproblem with Threading Pin
ekynox5-Jan-06 18:34
ekynox5-Jan-06 18:34 
AnswerRe: problem with Threading Pin
S. Senthil Kumar6-Jan-06 3:28
S. Senthil Kumar6-Jan-06 3:28 
GeneralRe: problem with Threading Pin
ekynox6-Jan-06 11:49
ekynox6-Jan-06 11:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.