Beispiel #1
0
        public virtual void Load(BinaryReader reader)
        {
            // before doing anything else, clear all the
            // persistent variables to their default state
            foreach (string wname in _wrappers_dict.Keys)
            {
                _wrappers_dict[wname].Clear();
            }
            BinIO.magic_read(reader, Name);
            this.PLoad(reader);
            string s;

            BinIO.string_read(reader, out s);
            if (s != "<component>")
            {
                throw new Exception("Expected string: <component>");
            }
            while (true)
            {
                // read tag
                BinIO.string_read(reader, out s);
                if (s == "</component>")
                {
                    break;
                }
                if (s != "<item>")
                {
                    throw new Exception("Expected string: <item>");
                }
                // read wrapper name
                BinIO.string_read(reader, out s);
                if (!_wrappers_dict.ContainsKey(s))
                {
                    throw new Exception(String.Format("Wrapper name '{0}' is not persisted", s));
                }
                // read wrapper data
                if (ComponentIO.level == 2)
                {
                    Global.Debugf("info", "{0," + (ComponentIO.level) + "}loading {1}", "", s);
                }
                _wrappers_dict[s].Load(reader);
                // read tag
                BinIO.string_read(reader, out s);
                if (s != "</item>")
                {
                    throw new Exception("Expected string: </item>");
                }
            }
            this.ReImport();
        }