コード例 #1
0
ファイル: Gump.cs プロジェクト: uotools/runuogdk
        public bool Load(XmlDocument doc)
        {
            try
            {
                OnLoadStarted(this, EventArgs.Empty);

                XmlElement  root      = doc.DocumentElement;
                XmlNodeList baseGumps = root.GetElementsByTagName("BaseGump");

                for (int i = baseGumps.Count - 1; i >= 0; i--)
                {
                    Type     type = Type.GetType(baseGumps[i].Attributes["type"].Value);
                    BaseGump gump = (BaseGump)Activator.CreateInstance(type);

                    string    xml     = baseGumps[i].OuterXml;
                    char[]    chars   = xml.ToCharArray();
                    byte[]    xmlData = Utility.ConvertCharToByteArray(chars);
                    XmlReader reader  = XmlReader.Create(new MemoryStream(xmlData, 0, xmlData.Length));
                    reader.Read();
                    gump.Deserialize(reader);
                    reader.Close();

                    Items.Add(gump);
                }

                OnLoadCompleted(this, EventArgs.Empty);
            }
            catch
            {
                return(false);
            }

            return(true);
        }