oop - Which pattern to use in replacement of composite with limited number of element type? -


I can have one object composed of components but each component has a type and it should be unique:

  Class Client {Set & lt; IComposite & gt; Element} interface iCompace site {string getType (); } Class status implies Icomposite {String getType ()} {return "status"}} class class uses the IComposite {String getType () {return "clientdate"}}  

So I think I could encapsulate the collection but each element should be unique, so only 1 position, only one port, but maybe I can create a new composite class which can be more than one.

How to design an idea?

Thanks a lot

You have a dictionary as a collection of your elements While adding the element to your unique ID (type in your case) as the key of the dictionary, you can check whether the element exists in the dictionary or not. So you can keep the collection with unique elements.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -