Exemplo n.º 1
0
        public override void Load(BinaryReader reader)
        {
            Global.Debugf("iodetail", "<componentlist>");
            string s;

            BinIO.string_read(reader, out s);
            if (s != "<componentlist>")
            {
                throw new Exception("Expected string: <componentlist>");
            }
            BinIO.string_read(reader, out s);
            int n;

            if (!int.TryParse(s, out n))
            {
                throw new Exception("Incorrect number format (count of component).");
            }
            data.Resize(n);
            for (int i = 0; i < n; i++)
            {
                data[i] = ComponentIO.load_component(reader);
                if (data[i] != null)
                {
                    Global.Debugf("iodetail", "   {0}", data[i].Name);
                }
            }
            BinIO.string_read(reader, out s);
            if (s != "</componentlist>")
            {
                throw new Exception("Expected string: </componentlist>");
            }
            Global.Debugf("iodetail", "</componentlist>");
        }
Exemplo n.º 2
0
        public void LoadOldFormat(BinaryReader reader)
        {
            string magic = BinIO.magic_get(reader, "linerec".Length);

            CHECK_ARG(magic == "linerec" || magic == "linerc2", "magic=='linerec' || magic=='linerc2'");
            PLoad(reader);
            IComponent comp   = ComponentIO.load_component(reader);
            IModel     cmodel = comp as IModel;

            classifier.Object = cmodel;
            counts.Clear();
            if (magic == "linerec")
            {
                PSet("minsize_factor", 0.0);
            }
            else if (magic == "linerc2")
            {
                Narray <int> intcount = counts;
                BinIO.narray_read(reader, intcount);
            }
        }
Exemplo n.º 3
0
        public static Linerec LoadLinerec(string filename)
        {
            FileStream   stream = new FileStream(filename, FileMode.Open, FileAccess.Read);
            BinaryReader reader = new BinaryReader(stream);

            try
            {
                IComponent comp = ComponentIO.load_component(reader);
                // loaded component is Linerec
                Linerec linerec = comp as Linerec;
                if (linerec != null)
                {
                    return(linerec);
                }

                // else component is IModel
                IModel cmodel = comp as IModel;
                if (cmodel != null)
                {
                    linerec = new Linerec();
                    linerec.SetClassifier(cmodel);
                    return(linerec);
                }
            }
            finally
            {
                reader.Close();
                stream.Close();
            }

            // try load old format
            Linerec linerec_old = new Linerec();

            linerec_old.LoadOldFormat(filename);
            return(linerec_old);
        }
Exemplo n.º 4
0
 public override void Load(BinaryReader reader)
 {
     data.SetComponent(ComponentIO.load_component(reader));
 }