Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Serializing / unserializing recursive objects
Message
De
08/08/2005 09:28:18
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01035740
Message ID:
01039281
Vues:
31
Hello Rick,

Sorry about coming back that late ! I have been away from here, thinking that my thread was dead (hopefully it is not now dead for real).

Thank you for your response ; the link you provided and your explanations were helpful. However, I still could not put a simple case to work like expected. Maybe I forgot to do something ? In the following code, the call to XmlToObject is always causing the error "Member GETNAMEDITEM does not evaluate to an object".

The two classes (basic_object.prg)
DEFINE CLASS MyCollection AS Custom
	oCollection=null
	FUNCTION INIT
		THIS.oCollection=CREATEOBJECT("Collection")
	ENDFUNC
	FUNCTION ToString
		LOCAL lcResult, loNumber
		lcResult=""
		FOR EACH loNumber IN THIS.oCollection
			lcResult=lcResult+loNumber.ToString()+";"
		ENDFOR
	ENDFUNC
ENDDEFINE

DEFINE CLASS MyNumber AS Custom
	nNumber=0
	FUNCTION INIT
	LPARAMETERS nNumber
		THIS.nNumber=nNumber
	ENDFUNC
	FUNCTION ToString
		RETURN ALLTRIM(STR(THIS.nNumber))
	ENDFUNC
ENDDEFINE
The calling code :
SET PROCEDURE TO wwUtils.prg, basic_objects.prg
SET CLASSLIB TO ../classlib/wwxml.vcx
LOCAL loXml, loColl, loColl2, loNumber, loNumber2, lcXml
loXml=CREATEOBJECT("wwxml")
loXml.lRecurseObjects=.T.
loColl=CREATEOBJECT("MyCollection")
loColl2=CREATEOBJECT("MyCollection")
loNumber=CREATEOBJECT("MyNumber",1)
loNumber2=CREATEOBJECT("MyNumber",2)
loColl.oCollection.Add(loNumber)
loColl2.oCollection.Add(loNumber2)
lcXml=loXml.ObjectToXml(loColl)
loColl2=loXml.XmlToObject(lcXml,loColl2)
? loColl2.ToString()
Regards,

David
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform