Пример #1
0
        /// <summary>
        /// Read entries from a stream.
        /// </summary>
        /// <param name="pwDatabase">Source database.</param>
        /// <param name="msData">Input stream to read the entries from.</param>
        /// <returns>Extracted entries.</returns>
        public static List<PwEntry> ReadEntries(PwDatabase pwDatabase, Stream msData)
        {
            Kdb4File f = new Kdb4File(pwDatabase);
            f.m_format = Kdb4Format.PlainXml;

            XmlDocument doc = new XmlDocument();
            doc.Load(msData);

            XmlElement el = doc.DocumentElement;
            if(el.Name != ElemRoot) throw new FormatException();

            List<PwEntry> vEntries = new List<PwEntry>();

            foreach(XmlNode xmlChild in el.ChildNodes)
            {
                if(xmlChild.Name == ElemEntry)
                {
                    PwEntry pe = f.ReadEntry(xmlChild);
                    pe.Uuid = new PwUuid(true);

                    foreach(PwEntry peHistory in pe.History)
                        peHistory.Uuid = pe.Uuid;

                    vEntries.Add(pe);
                }
                else { Debug.Assert(false); }
            }

            return vEntries;
        }
Пример #2
0
        /// <summary>
        /// Read entries from a stream.
        /// </summary>
        /// <param name="pwDatabase">Source database.</param>
        /// <param name="msData">Input stream to read the entries from.</param>
        /// <returns>Extracted entries.</returns>
        public static List <PwEntry> ReadEntries(PwDatabase pwDatabase, Stream msData)
        {
            Kdb4File f = new Kdb4File(pwDatabase);

            f.m_format = Kdb4Format.PlainXml;

            XmlDocument doc = new XmlDocument();

            doc.Load(msData);

            XmlElement el = doc.DocumentElement;

            if (el.Name != ElemRoot)
            {
                throw new FormatException();
            }

            List <PwEntry> vEntries = new List <PwEntry>();

            foreach (XmlNode xmlChild in el.ChildNodes)
            {
                if (xmlChild.Name == ElemEntry)
                {
                    PwEntry pe = f.ReadEntry(xmlChild);
                    pe.Uuid = new PwUuid(true);

                    foreach (PwEntry peHistory in pe.History)
                    {
                        peHistory.Uuid = pe.Uuid;
                    }

                    vEntries.Add(pe);
                }
                else
                {
                    Debug.Assert(false);
                }
            }

            return(vEntries);
        }