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

  • Thread starter Thread starter roland
  • Start date Start date
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
 
I think the easiest way would be to throw an Exception if the restricted
methods are used without having a license.


Chris
 
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
 
Back
Top