mardi 31 décembre 2019

How the client can have access to the concreteproducts in Factory pattern

When implementing the Factory Method in c#, I have several concrete products let's say ConcretProductA and ConcretProductB where every ConcretProduct has a public string Name. The problem I am facing is that I need to create a list of all the ConcretProducts' names. This list will be used for example to enable the user to select one product in a Combobox on runtime.

So I need the ability to read all the ConcretProducts' names, without instantiating instances for all the available concretProducts, read the name (i will have to make it static most probably) and store it in an enum for example. If not directly could the interface help me?

Could this work? or there is a better solution?

Aucun commentaire:

Enregistrer un commentaire