Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem with DeserializeTag (Read 1113 times)
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Problem with DeserializeTag
Aug 9th, 2007 at 5:26am
Print Post  
Hello,

I save my diagrams in a XML file with the methods provided by the FlowChart.NET library. I also use the SerializeTag and DeserializeTag methods. But know I have one question.

When I deserialize the Tag from an object (e.g. Box), the type returned is System.RunTimeType instead of the type I stored in the XML Tag (e.g. CustomType).

It is all stored correctly, <Tag>CustomType;CustomType</Tag>, but the DeserializeTag always returns e.Tag = null;

What did I miss? I know it has something to do with reflection, but maybe you got an idea.

The code:

Code
Select All
        private static void DeserializeTag(object sender, MindFusion.Diagramming.Xml.SerializeTagArgs e)
        {
            string type, val;
            int pos = e.Representation.IndexOf(";");
            if (pos == -1)
                return;
            type = e.Representation.Substring(0, pos);  // this is "CustomType" of Type String
            val = e.Representation.Substring(pos + 1); //this is "CustomType" of Type String
            Type t = Type.GetType(type); //this is System.RuntimeType
            object tag = null;
            if (t == typeof(string)) //becomes false
                tag = val;
            else if (t == typeof(int)) // also false
                tag = XmlConvert.ToInt32(val);
            e.Tag = tag; // tag = null
        }
 



Thank you in advance!

Alex

PS: CustomType is declared in the same assembly and the code is also in the same namespace.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with DeserializeTag
Reply #1 - Aug 9th, 2007 at 8:37am
Print Post  
Hi,

You might have to save the full type name, including the assembly name, when serializing tags this way. Why not compare the types as strings? e.g.

if (type == "String")
     ...

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint