Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Custom class with DataSession?
Message
 
 
À
31/07/2001 17:26:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00537926
Message ID:
00538241
Vues:
12
This message has been marked as the solution to the initial question of the thread.
>>Why does the Session class have to be a container?
>
>I am trying to create a 'business object' (not a COM object though) based on Session class and I need to add some custom data objects. I've looked at Session because, I assume, it has a datasession and has a small footprint.
>

Session is relatively light weight in terms of exposed PEMs. It isn't when you are talking about VFP objects with datasessions attached. That would be the FormSet object, but who wants to use that. ;-)

>>It does have a AddProperty method and you can use it to create properties and assign objects to those properties.
>
>Appreciate if you could provide me a very simple example to assign an object to a property inside the session class definition.

See simple example below:
define class MyBizObj as Session
oDataObject1 = .NULL.
oDataObject2 = .NULL.

procedure Init
local llretval

llretval = THIS.SetUpDataObjects()
return llretval
endproc

procedure SetUpDataObjects
local llretval
llretval = .T.

With THIS
   .oDataObject1 = createobject('MyDataObjectClass')
   .oDataObject2 = createobject('MyDataObjectClass')

   llretval = vartype(.oDataObject1) = 'O' and vartype(.oDataObject2) = 'O'
Endwith

return llretval
endproc

procedure Destroy
THIS.oDataObject1 = .NULL.
THIS.oDataObject2 = .NULL.
endproc

procedure Release
release THIS
endproc
enddefine
You simply create properties to hold object references and assign objects to those properties. In the Destroy, you clean up to avoid dangling object references.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform