Exemple #1
0
        public static IComponent load_component(BinaryReader reader)
        {
            IComponent result = null;
            string     s;

            BinIO.string_read(reader, out s);
            Global.Debugf("iodetail", "{0}[got {1}]", level, s);
            if (s == "<object>")
            {
                level++;
                BinIO.string_read(reader, out s);
                if (level <= 2)
                {
                    Global.Debugf("info", "{0," + (level - 1) + "}loading component {1}", "", s);
                }

                Global.Debugf("iodetail", "{0}[constructing {1}]", level, s);
                result = ComponentCreator.MakeComponent(s);
                result.Load(reader);
                BinIO.string_read(reader, out s);
                if (s != "</object>")
                {
                    throw new Exception("Expected string: </object>");
                }
                level--;
            }
            else if (s.StartsWith("OBJ:"))
            {
                s = s.Substring(4);
                level++;
                Global.Debugf("iodetail", "{0}[constructing {1}]", level, s);
                result = ComponentCreator.MakeComponent(s);
                result.Load(reader);
                BinIO.string_read(reader, out s);
                if (s != "OBJ:END")
                {
                    throw new Exception("Expected string: </object>");
                }
                level--;
            }
            Global.Debugf("iodetail", "{0}[done]", level);
            return(result);
        }
 public T CreateComponent(string name)
 {
     _component = ComponentCreator.MakeComponent <T>(name);
     return(_component);
 }