/// <summary> /// Compares the data of two <see cref="CustomData"/> instances. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { KdbxCustomData other = obj as KdbxCustomData; if (other == null) { return(false); } if (this.data.Count != other.data.Count) { return(false); } var myData = this.data.Select(kvp => new Tuple <string, string>(kvp.Key, kvp.Value)).ToList(); var otherData = other.data.Select(kvp => new Tuple <string, string>(kvp.Key, kvp.Value)).ToList(); for (int i = 0; i < myData.Count; i++) { if (myData[i].Item1 != otherData[i].Item1 || myData[i].Item2 != otherData[i].Item2) { return(false); } } return(true); }
protected KdbxNode(XElement xml, KdbxSerializationParameters parameters) : base(xml) { Uuid = GetUuid("UUID"); IconID = GetInt("IconID"); CustomIconUuid = GetUuid("CustomIconUUID", false); Times = new KdbxTimes(GetNode(KdbxTimes.RootName), parameters); XElement dataElement = GetNode(KdbxCustomData.RootName); if (dataElement != null) { CustomData = new KdbxCustomData(dataElement); } }
/// <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; } }