Link to home
Start Free TrialLog in
Avatar of ba272
ba272

asked on

How do I create an interface which is added at runtime

Hi,

I need to conditionally add an interface to an object which will add certain capabilties when the program loads.  So if the program needs to load in one way, the interface will not be used.  In another way it will be added.

Is this possible?

Thanks,
Bob
Avatar of jonorossi
jonorossi

Are you talking about a Graphic User Interface or a code interface? GUIs are plain code, you can see this if you take a look in the designer generated code (FormName.Designer.cs in 2005); you can also easily show and hide controls on your forms. If you are talking about code interfaces then you cannot do what you are asking because an interface is just a skeleton or contract that the class has to implement what it says. A base class will add extra code but you cannot add this at runtime because it is done by the compiler when you build. I assume you are talking about controls/objects on a form. Let me know if you need more info.

Jono
ASKER CERTIFIED SOLUTION
Avatar of mjmarlow
mjmarlow
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ba272

ASKER

I think this concept of a decorator class might be what I need.  I'll explain in a little more detail here.

I have an order object, which has quite an extensive amount of code in it, and is complete when my program operates in conjunction to a given point of sale system (POS).  But in order to modify the interface for a new POS I need to add a few more properties to the Order object.  But I don't want to be sloppy down the road, when creating an interface to a third POS by accidentally mis-using these properties, which are reserved for this new POS.

So I have altered my database properties to describe the POS name to use, so while loading, my program has the ability to dynamically adjust to various POS's.

Is this a proper use of a Decorator class?

Thank for the help,
Bob
Avatar of ba272

ASKER

I wonder if I wouldn't be better off simply overriding the Order object and only instantiating the nw type when using the new POS.

I guess I overlooked the most typical way to solve this problem.  Thanks.

Bob