Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
roland - 09 Oct 2004 14:58 GMT
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
Christopher Kimbell - 09 Oct 2004 17:15 GMT
I think the easiest way would be to throw an Exception if the restricted
methods are used without having a license.

Chris

> This is what I want to achieve:
> A control is exposing different methods in design mode, according to the
[quoted text clipped - 33 lines]
> Thanks in advance,
> Roland
roland - 10 Oct 2004 10:46 GMT
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

> I think the easiest way would be to throw an Exception if the restricted
> methods are used without having a license.
[quoted text clipped - 38 lines]
> > Thanks in advance,
> > Roland

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.