Beispiel #1
0
        public override bool Equals(object obj)
        {
            KdbxCustomIcons other = obj as KdbxCustomIcons;

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

            return(XElement.DeepEquals(this.originalXml, other.originalXml));
        }
Beispiel #2
0
        /// <summary>
        /// Parses out a metadata element from XML.
        /// </summary>
        /// <param name="xml">XML to deserialize.</param>
        /// <param name="headerBinaries">Binaries that have been pre-parsed from a header.</param>
        /// <param name="parameters">Parameters controlling serialization.</param>
        public KdbxMetadata(XElement xml, IEnumerable <ProtectedBinary> headerBinaries, KdbxSerializationParameters parameters)
            : base(xml)
        {
            if (headerBinaries == null)
            {
                throw new ArgumentNullException(nameof(headerBinaries));
            }

            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            Generator                  = GetString("Generator");
            HeaderHash                 = GetString("HeaderHash");
            DatabaseName               = GetString("DatabaseName");
            DatabaseNameChanged        = GetDate("DatabaseNameChanged", parameters);
            DatabaseDescription        = GetString("DatabaseDescription");
            DatabaseDescriptionChanged = GetDate("DatabaseDescriptionChanged", parameters);
            DefaultUserName            = GetString("DefaultUserName");
            DefaultUserNameChanged     = GetDate("DefaultUserNameChanged", parameters);
            MaintenanceHistoryDays     = GetInt("MaintenanceHistoryDays");
            DbColor              = GetNullableColor("Color");
            MasterKeyChanged     = GetDate("MasterKeyChanged", parameters, false);
            MasterKeyChangeRec   = GetInt("MasterKeyChangeRec", -1);
            MasterKeyChangeForce = GetInt("MasterKeyChangeForce", -1);
            MemoryProtection     = new KdbxMemoryProtection(GetNode(KdbxMemoryProtection.RootName));

            XElement iconsElement = GetNode(KdbxCustomIcons.RootName);

            if (iconsElement != null)
            {
                CustomIcons = new KdbxCustomIcons(iconsElement);
            }
            else
            {
                CustomIcons = null;
            }

            RecycleBinEnabled          = GetBool("RecycleBinEnabled");
            RecycleBinUuid             = GetUuid("RecycleBinUUID");
            RecycleBinChanged          = GetDate("RecycleBinChanged", parameters);
            EntryTemplatesGroup        = GetUuid("EntryTemplatesGroup");
            EntryTemplatesGroupChanged = GetDate("EntryTemplatesGroupChanged", parameters);
            HistoryMaxItems            = GetInt("HistoryMaxItems", -1);
            HistoryMaxSize             = GetInt("HistoryMaxSize", -1);
            LastSelectedGroup          = GetUuid("LastSelectedGroup");
            LastTopVisibleGroup        = GetUuid("LastTopVisibleGroup");

            XElement binariesElement = GetNode(KdbxBinaries.RootName);

            if (parameters.BinariesInXml)
            {
                if (binariesElement != null)
                {
                    Binaries = new KdbxBinaries(binariesElement, parameters);
                }
                else
                {
                    Binaries = new KdbxBinaries();
                }
            }
            else
            {
                // Populate with values from binary inner header
                Binaries = new KdbxBinaries(headerBinaries);
            }

            XElement customDataElement = GetNode(KdbxCustomData.RootName);

            if (customDataElement != null)
            {
                CustomData = new KdbxCustomData(customDataElement);
            }
            else
            {
                CustomData = null;
            }
        }