Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
akchase47 #1
Member since Jul 2011 · 8 posts
Group memberships: Members
Show profile · Link to this post
Subject: Making a copy of a Node
Hello,

I want to make a copy of a Presence stanza that has been received on my server,

if i do this:

Presence presence2 = presence;

It reference copies presence to presence2 and any changes made to either presence or presence2 change both objects.

Is there a way to actually make a complete copy of presence into presence2 so that it is separate from presence?

So that changes to one doesn't effect the other?
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by akchase47:
Is there a way to actually make a complete copy of presence into presence2 so that it is separate from presence?

So that changes to one doesn't effect the other?

no there isn't. You have to create a clone method for this. Then you could use code like the following:

  1. var pres2 = pres1.Clone();

Alex
Avatar
akchase47 #3
Member since Jul 2011 · 8 posts
Group memberships: Members
Show profile · Link to this post
Ok, sounds good, was just hoping there was some magic code in there so I didn't have to implement IClonable on most every class in the project.

Thanks,
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you could create a generic clone member on the Element class where all other Elements are derived from.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS