Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Restricted access to a class
Message
De
24/05/2012 17:39:45
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Titre:
Restricted access to a class
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01544358
Message ID:
01544358
Vues:
72
I have a class which I only want to expose access from its own DLL. However, another class from this DLL is creating an instance of that class. Then, from that instance, that class exposes a method or a property of the class that should not be available outside the DLL.

So, lets say a class is creating an instance of the other class as:
        Public oUpload As Framework.Upload = New Framework.Upload(oProcess)
And, this class can expose oUpload to the application as it is public. So, the application can then do things like this:
        ' Assign the Excel file
        loImport.cSource = oUpload.cFile
So, at this point, the Upload class is defined Public and the other class creating an instance of it is declaring oUpload as Public. Thus, the application can gain access to the Upload methods and properties which are public.

Having said that, it means the application can create an instance of the Upload class. This is what I do not want. If I put Friend for the class declaration, this will allow the other class to create an instance of it but will not allow the other class to declare oUpload as Public.

Is there a way to negotiate with that need?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform