-
Set Scope of Class Members Dynamically
Is there a way in VB.net that you can dynamically set (at runtime) the scope
of each class member (whether a property or a method).
A sample scenario would be:
I have a class named "ProjectTemplate" that has a number of properties plus
a Delete and Save method.
I have a another class, the "Project" class", that also has a number of properties
and one of these properties is a "ProjectTemplate" class.
Two ways of using the "ProjectTemplate" class:
1. I could instantiate a "ProjectTemplate" class from a factory class (where
a user can manage project types).
2. Or use it as an aggregate/property of the "Project" class.
On #1, scope of the delete and save methods of the "ProjectTemplate" class
should be set to Public. While on #2, the delete and save methods of the
"ProjectTemplate" class should be invisible (or has a scope of private).
Is there a solution for this? Suggestions?
Thanks.
-
Re: Set Scope of Class Members Dynamically
"Ian Diaz" <idiaz@pciasia.com> wrote
>
> Is there a way in VB.net that you can dynamically set (at runtime) the scope
> of each class member (whether a property or a method).
It sounds to me like you want some base functionality, for one type of
object, plus an extended Save and Delete on another object.
So, the object that exposes the Save and Delete methods should inherit
from the base class, that has no Save or Delete.
> Two ways of using the "ProjectTemplate" class:
> 1. I could instantiate a "ProjectTemplate" class from a factory class (where
> a user can manage project types).
> 2. Or use it as an aggregate/property of the "Project" class.
#1 would be the inherited class, to expose those extra properties, and
#2 would be the base class, that has only basic functionality.
That is a bit like the TextBox and Label controls inheriting from the TextControl
class, is it not? The TextControl class has the basic functionality of what a text
based control needs, and the Textboxes and Labels add their own properties
and methods.
LFS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks