Class explosing its methods, properties, etc conditionally: is it possible?

R

roland

This is what I want to achieve:
A control is exposing different methods in design mode, according to the
presence of a license.

For instance: when an instance is created of the control (class) and no
license is found, method A is available but method B not.
The license is a class variable, but only resolved at the time the first
instance is being instantiated (new()).
The purpose is to avoid a runtime license. The
SetSavedLicenseKey/GetSavedLicenseKey is using the calling assembly to store
the license key and I don't like (=trust) this solution!

I know you can enforce a different "behaviour" from a class with interfaces:

public class Class1
implements I1,I2
....
end class
public interface I1
....
end interface
public interface I2
....
end interface

When you define an object as I1 and instantiate this object as Class1, you
will only have access to the methods of I1. But I don't see a possibility to
enforce the restriction to expose the methods of one interface from within
the class itself.

Can anybody pointing me towards a solution (not necessarely with
interfaces!) ?
Thanks in advance,
Roland
 
C

Christopher Kimbell

I think the easiest way would be to throw an Exception if the restricted
methods are used without having a license.


Chris
 
R

roland

Chris
Thanks for answering.
I was actually hoping to find a more subtle appproach ;-) But your idea is
certainly useable if nothing better can be found!
Apologies for the typo in the message title: "explosing" should be
"exposing", I hope that most people figured that out anyway.
Greetings, Roland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top