KeePassLib.Serialization.Kdb4File.WriteEntry C# (CSharp) Метод

WriteEntry() приватный Метод

private WriteEntry ( PwEntry pe, bool bIsHistory ) : void
pe PwEntry
bIsHistory bool
Результат void
        private void WriteEntry(PwEntry pe, bool bIsHistory)
        {
            Debug.Assert(pe != null); if(pe == null) throw new ArgumentNullException("pe");

            m_xmlWriter.WriteStartElement(ElemEntry);

            WriteObject(ElemUuid, pe.Uuid);
            WriteObject(ElemIcon, (int)pe.IconId);

            if(pe.CustomIconUuid != PwUuid.Zero)
                WriteObject(ElemCustomIconID, pe.CustomIconUuid);

            WriteObject(ElemFgColor, StrUtil.ColorToUnnamedHtml(pe.ForegroundColor, true), false);
            WriteObject(ElemBgColor, StrUtil.ColorToUnnamedHtml(pe.BackgroundColor, true), false);
            WriteObject(ElemOverrideUrl, pe.OverrideUrl, true);
            WriteObject(ElemTags, StrUtil.TagsToString(pe.Tags, false), true);

            WriteList(ElemTimes, pe);

            WriteList(pe.Strings, true);
            WriteList(pe.Binaries);
            WriteList(ElemAutoType, pe.AutoType);

            if(!bIsHistory) WriteList(ElemHistory, pe.History, true);
            else { Debug.Assert(pe.History.UCount == 0); }

            m_xmlWriter.WriteEndElement();
        }

Usage Example

        /// <summary>
        /// Write entries to a stream.
        /// </summary>
        /// <param name="msOutput">Output stream to which the entries will be written.</param>
        /// <param name="pwDatabase">Source database.</param>
        /// <param name="vEntries">Entries to serialize.</param>
        /// <returns>Returns <c>true</c>, if the entries were written successfully to the stream.</returns>
        public static bool WriteEntries(Stream msOutput, PwDatabase pwDatabase, PwEntry[] vEntries)
        {
            Kdb4File f = new Kdb4File(pwDatabase);

            f.m_format = Kdb4Format.PlainXml;

            XmlTextWriter xtw = null;

            try { xtw = new XmlTextWriter(msOutput, new UTF8Encoding(false)); }
            catch (Exception) { Debug.Assert(false); return(false); }
            if (xtw == null)
            {
                Debug.Assert(false); return(false);
            }

            f.m_xmlWriter = xtw;

            xtw.Formatting  = Formatting.Indented;
            xtw.IndentChar  = '\t';
            xtw.Indentation = 1;

            xtw.WriteStartDocument(true);
            xtw.WriteStartElement(ElemRoot);

            foreach (PwEntry pe in vEntries)
            {
                f.WriteEntry(pe, false);
            }

            xtw.WriteEndElement();
            xtw.WriteEndDocument();

            xtw.Flush();
            xtw.Close();
            return(true);
        }
All Usage Examples Of KeePassLib.Serialization.Kdb4File::WriteEntry