Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Bug in OnSerializeTag and OnDeserializeTag (Read 1760 times)
castefani
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Feb 26th, 2009
Bug in OnSerializeTag and OnDeserializeTag
Mar 26th, 2009 at 5:00pm
Print Post  
Derive a class of Diagram and outweighs the methods
override void OnSerializeTag
and
protected override void OnDeserializeTag

Calling SaveToString after LoadFromString then SaveToString, beast last call and subsequent calls are not the methods OnSerializeTag and OnDeserializeTag

EX:

In the method test (), the 2nd called SaveToString, the methods OnSerializeTag and OnDeserializeTag will not be called.



class MyDiagram : Diagram

string diagramId = "Test";

protected override void OnSerializeTag(SerializeTagEventArgs e)
{
base.OnSerializeTag(e);
XElement el;
var els = e.Context.XDocument.Root.Descendants("MyData").ToList();
if (els.Count > 0)
el = els[0];
else
{
el = new XElement("MyData");
e.Context.XDocument.Root.Add(el);
}
e.Context.WriteString(diagramId, "DiagramId", el);
}
ª
protected override void OnDeserializeTag(SerializeTagEventArgs e)
{
base.OnDeserializeTag(e);
var els = e.Context.XDocument.Root.Descendants("MyData").ToList();
if (els.Count > 0)
{
var el = els[0];
diagramId = e.Context.ReadString("DiagramId", el, Guid.NewGuid().ToString());
}
}

public void TEST()
{
           string save = this.SaveToString(SaveToStringFormat.Xml);
           this.LoadFromString(save);
           save = this.SaveToString(SaveToStringFormat.Xml);

           this.LoadFromString(save);
           save = this.SaveToString(SaveToStringFormat.Xml);
           this.LoadFromString(save);
}

}
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bug in OnSerializeTag and OnDeserializeTag
Reply #1 - Apr 6th, 2009 at 12:21pm
Print Post  
I can't quite understand this, but you should also set e.Handled = true in SerializeTag and DeserializeTag handlers.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint