Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP COM Design Problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
VFP COM Design Problem
Divers
Thread ID:
01214563
Message ID:
01214563
Vues:
68
I have PRG-based classlib that will be compiled into a DLL. There are classes in
the DLL that I only want instantiated through methods in the main class.

The problem is how to prevent a class from being instantiaed from outside the
main class.

One solution that I came up with is this:
** Main Class
PROCEDURE GetChildClass() AS Object

  LOCAL oRetVal AS Object

  PUBLIC gb_AllowChildClass && This must exist in the child class Init

  oRetVal = This.GetChildClass()

ENDPROC
And in the Child class's Init:
PROCEDURE Init()

  LOCAL bRetVal AS Boolean
  bRetVal = .T.

  IF TYPE("AllowChildClass") = "U"
    bRetVal = .F.
  ENDIF

  RETURN bRetVal

ENDPROC
Since the whole thing is in a DLL, it's in its own session, so there should
be no issue with using a public variable.

Still, I don't really feel good about it.

Anyone have a better way?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform