Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting Children
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Divers
Thread ID:
00621025
Message ID:
00621936
Vues:
15
Hey guys,

How about something like the code listed below?...it handles any number of parameters because you send a single, discrete parameter as tuParm OR, you can send a parameter object (an instance of CParameter) that can contain an unlimited number of parameters.

Notice the method is expecting a logical return value from the child object method. This provides a hook that allows any child object to return .F. which tells SendChildMessage() to stop sending messages to subsequent child objects. I won't be using this method at the Framework level, because in most cases, the calls to child business objects are not that simple...I'm creating this with the intent of MM developers calling their own custom business object methods.

*---------------------- Location Section ------------------------
* Library: Kbizness.vcx
* Class: Kbizobj
* Method: Sendchildmessage()
*----------------------- Usage Section --------------------------
*) Description:
*) Sends the specified message to all child business objects.
*) If any child returns .F., messages are not sent to
*) subsequent child objects.

* Scope: Public
* Parameters:
* 1. tcMessage - Method to be called on child objects
* 2. tuParm - Parameter. Multiple parameters can be sent
* via a Parameter object
*$ Usage:
*$
* Returns: Logical .T. if all children return true, otherwise
* .F.
*--------------------- Maintenance Section ----------------------
* Change Log:
* CREATED 02/19/2002 - KJM
* MODIFIED
******************************************************************
LPARAMETERS tcMessage, tuParm

LOCAL lnObjCount, lnCount, loChildBizObj, llRetVal, lcMessageCall

IF TYPE("This.RefBizObj") == "O"

*--- Get the number of child objects ---*
lnObjCount = This.RefBizObj.GetObjectCount()

*--- Build the message call ---*
IF PCOUNT() = 1
lcMessageCall = "loChildBizObj."+tcMessage+"()"
ELSE
lcMessageCall = "loChildBizObj."+tcMessage+"(tuParm)"
ENDIF

*--- Iterate through the child objects and send each one the message ---*
FOR lnCount = 1 TO lnObjCount
loChildBizObj = This.RefBizObj.Get(lnCount)
IF PEMSTATUS(loChildBizObj, tcMessage, 5)
llRetVal = &lcMessageCall
IF NOT llRetVal
EXIT
ENDIF
ENDIF
ENDFOR
ENDIF

RETURN llRetVal


Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform