Set Scope of Class Members Dynamically


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Set Scope of Class Members Dynamically

  1. #1
    Ian Diaz Guest

    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.

  2. #2
    Larry Serflaten Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center