treeview - C# Clone a specialized TreeNode containing another Object of type Object -


i have been searching simple solution cloning of object containing other objects.

public class tpftestcasetreenode: treenode, icloneable {     public object obj;      public tpftestcasetreenode(string title, object o)     {         // set attributes treenode         text = title; // not sure 1 need         name = title; // not sure 1 need          // , additionally, remember test case object         obj = o;     } }  

for cloning, using :

foreach(treenode t in listalltestcases) {     if(t.name.equals(testcaseiddesc))     {         thenode = (treenode)((icloneable)t).deepclone();                          } } 

listalltestcases contain tree nodes of type "tpftestcasetreenode".

"t" in loop, contain valid value "obj" per debugger mode

i have tried normal clone() , deepclone() well, none of them able clone state of object "obj". remains null in cloned object treenode "thenode".

can provide plausible explanation why cloning of object containing object failing here? here 2 states initial before cloning , after cloning. initial state cloned object

please note have tried binaryformatter(serialize/ deserialize mechanism) well. still, object "obj" null.

so finally, had use treenode "tag" property , assign "obj" it. here deepclone() or clone() did not clone tag property value.

basically had loop on each property of actual object , build cloned one.

such hassle custom types of treenode, working fine now.

thanks valuable inputs.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -