예제 #1
0
    public static void Parse(VEObject obj, XmlElement xml)
    {
        string typename = obj.GetType().FullName;

        if (!TypeDict.ContainsKey(typename))
        {
            throw new Exception("Object [" + obj.ID + "] ToXML failed: Unknown Type");
        }
        XMLMemberCollection mc = TypeDict[typename];

        foreach (XMLMemberDesc mem in mc.Members)
        {
            object value = XMLIO.ReadValue(xml, mem.Attr, mem.Type, mem.Necessary, mem.DefaultValue);
            if (value != null)
            {
                mem.SetValue(obj, value);
            }
        }
    }
예제 #2
0
    public static string ToXML(VEObject obj)
    {
        string typename = obj.GetType().FullName;

        if (!TypeDict.ContainsKey(typename))
        {
            Debug.LogError("Object [" + obj.ID + "] ToXML failed: Unknown Type");
            return("");
        }
        XMLMemberCollection mc = TypeDict[typename];
        string xml             = "<" + mc.Name + " ";

        foreach (XMLMemberDesc mem in mc.Members)
        {
            xml += XMLIO.WriteValue(mem.Attr, mem.GetValue(obj), mem.Type, mem.Necessary, mem.DefaultValue);
        }
        xml += "/>\r\n";
        return(xml);
    }