//**************************************************************************************************** public override System.Object Clone() { ArrayVar res = new ArrayVar(); int li = 0; SingleVar e = null; while (li < m_list.Count) { e = (SingleVar) m_list[li++]; if (e != null) res.m_list.Add(e.Clone()); else res.m_list.Add(null); } return res; }
public void Restore() { FileInfo fi = new FileInfo(FILE_NAME); m_list = new ArrayList(); m_n = 0; if (!fi.Exists) return; BinaryReader br = new BinaryReader(fi.Open(FileMode.Open)); try { int count = br.ReadInt32(); for (int i = 0; i < count; i++) { Pair p = new Pair(); p.m_str = br.ReadString(); char vt = br.ReadChar(); switch (vt) { case 's': { p.m_var = new StringVar(br.ReadString()); break; } case 'i': { p.m_var = new IntVar(br.ReadInt32()); break; } case 'r': { p.m_var = new RealVar(br.ReadDouble()); break; } case 'a': { int elcount = br.ReadInt32(); ArrayVar av = new ArrayVar(); for (int j = 0; j < elcount; j++) { char elt = br.ReadChar(); switch (elt) { case 'n': { break; } case 's': { av.setAt(j, new StringVar(br.ReadString())); break; } case 'r': { av.setAt(j, new RealVar(br.ReadDouble())); break; } case 'i': { av.setAt(j, new IntVar(br.ReadInt32())); break; } default: { throw new NamespaceSerializationException(); } } } p.m_var = av; break; } default: { throw new NamespaceSerializationException(); } } m_list.Add(p); m_n++; } } catch { m_n = 0; m_list = new ArrayList(); throw new NamespaceSerializationException(); } finally { br.Close(); } }