示例#1
0
        /// <summary>
        /// Checks two binary nodes for equality. Nodes are equal if they have the
        /// same ID and same data.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            KdbxBinary other = obj as KdbxBinary;

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

            return(Id == other.Id && BinaryData.Equals(other.BinaryData));
        }
示例#2
0
        /// <summary>
        /// Parses a collection of binaries from the given XML.
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="parameters"></param>
        public KdbxBinaries(XElement xml, KdbxSerializationParameters parameters)
            : base(xml)
        {
            this.binaries = new SortedDictionary <int, KdbxBinary>();

            foreach (XElement ele in GetNodes(KdbxBinary.RootName))
            {
                KdbxBinary bin = new KdbxBinary(ele, parameters);
                if (this.binaries.ContainsKey(bin.Id))
                {
                    throw new KdbxParseException(
                              ReaderResult.FromXmlParseFailure($"Duplicate binary key {bin.Id}")
                              );
                }

                this.binaries.Add(bin.Id, bin);
            }
        }