예제 #1
0
        public override bool Equals(object obj)
        {
            KdbxRoot other = obj as KdbxRoot;

            if (other == null)
            {
                return(false);
            }

            return(DatabaseGroup.Equals(other.DatabaseGroup) && XElement.DeepEquals(this.deletedObjs, other.deletedObjs));
        }
예제 #2
0
        /// <summary>
        /// Parses a KeePass document from the specified XML.
        /// </summary>
        /// <param name="xml">XML to deserialize.</param>
        /// <param name="headerBinaries">Any binaries that were parsed from a header.</param>
        /// <param name="rng">RNG used to encrypt protected strings.</param>
        /// <param name="parameters">Parameters controlling serialization.</param>
        public KdbxDocument(XElement xml, IEnumerable <ProtectedBinary> headerBinaries, IRandomNumberGenerator rng, KdbxSerializationParameters parameters)
            : base(xml)
        {
            XElement metadata = GetNode(KdbxMetadata.RootName);

            if (metadata == null)
            {
                throw new KdbxParseException(
                          ReaderResult.FromXmlParseFailure($"Document has no {KdbxMetadata.RootName} node")
                          );
            }
            Metadata = new KdbxMetadata(metadata, headerBinaries, parameters);

            XElement root = GetNode(KdbxRoot.RootName);

            if (root == null)
            {
                throw new KdbxParseException(
                          ReaderResult.FromXmlParseFailure($"Document has no {KdbxRoot.RootName} node")
                          );
            }
            Root = new KdbxRoot(root, rng, Metadata, parameters);
        }
예제 #3
0
 /// <summary>
 /// Initializes an empty document with provided metadata.
 /// </summary>
 /// <param name="metadata"></param>
 public KdbxDocument(KdbxMetadata metadata)
 {
     Metadata = metadata;
     Root     = new KdbxRoot();
 }