If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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).

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.