/// <summary> /// Assign properties to the current group based on a template group. /// </summary> /// <param name="pgTemplate">Template group. Must not be <c>null</c>.</param> /// <param name="bOnlyIfNewer">Only set the properties of the template group /// if it is newer than the current one.</param> public void AssignProperties(PwGroup pgTemplate, bool bOnlyIfNewer) { Debug.Assert(pgTemplate != null); if (pgTemplate == null) { throw new ArgumentNullException("pgTemplate"); } // Template UUID should be the same as the current one Debug.Assert(m_uuid.EqualsValue(pgTemplate.m_uuid)); if (bOnlyIfNewer) { if (pgTemplate.m_tLastMod < m_tLastMod) { return; } } m_strName = pgTemplate.m_strName; m_strNotes = pgTemplate.m_strNotes; m_pwIcon = pgTemplate.m_pwIcon; m_pwCustomIconID = pgTemplate.m_pwCustomIconID; m_tCreation = pgTemplate.m_tCreation; m_tLastMod = pgTemplate.m_tLastMod; m_tLastAccess = pgTemplate.m_tLastAccess; m_tExpire = pgTemplate.m_tExpire; m_bExpires = pgTemplate.m_bExpires; m_uUsageCount = pgTemplate.m_uUsageCount; m_pwLastTopVisibleEntry = pgTemplate.m_pwLastTopVisibleEntry; }
internal static void RemoveCustomIconUuid(PwEntry pe, List<PwUuid> vToDelete) { PwUuid uuidThis = pe.CustomIconUuid; if(uuidThis.EqualsValue(PwUuid.Zero)) return; foreach(PwUuid uuidDelete in vToDelete) { if(uuidThis.EqualsValue(uuidDelete)) { pe.CustomIconUuid = PwUuid.Zero; break; } } foreach(PwEntry peHistory in pe.History) RemoveCustomIconUuid(peHistory, vToDelete); }
public bool DeleteCustomIcons(List<PwUuid> vUuidsToDelete) { Debug.Assert(vUuidsToDelete != null); if(vUuidsToDelete == null) throw new ArgumentNullException("vUuidsToDelete"); if(vUuidsToDelete.Count <= 0) return true; GroupHandler gh = delegate(PwGroup pg) { PwUuid uuidThis = pg.CustomIconUuid; if(uuidThis.EqualsValue(PwUuid.Zero)) return true; foreach(PwUuid uuidDelete in vUuidsToDelete) { if(uuidThis.EqualsValue(uuidDelete)) { pg.CustomIconUuid = PwUuid.Zero; break; } } return true; }; EntryHandler eh = delegate(PwEntry pe) { RemoveCustomIconUuid(pe, vUuidsToDelete); return true; }; gh(m_pgRootGroup); if(!m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh)) { Debug.Assert(false); return false; } foreach(PwUuid pwUuid in vUuidsToDelete) { int nIndex = GetCustomIconIndex(pwUuid); if(nIndex >= 0) m_vCustomIcons.RemoveAt(nIndex); } return true; }
public bool DeleteCustomIcons(List <PwUuid> vUuidsToDelete) { Debug.Assert(vUuidsToDelete != null); if (vUuidsToDelete == null) { throw new ArgumentNullException("vUuidsToDelete"); } if (vUuidsToDelete.Count <= 0) { return(true); } EntryHandler eh = delegate(PwEntry pe) { PwUuid uuidThis = pe.CustomIconUuid; if (uuidThis == PwUuid.Zero) { return(true); } foreach (PwUuid uuidDelete in vUuidsToDelete) { if (uuidThis.EqualsValue(uuidDelete)) { pe.CustomIconUuid = PwUuid.Zero; break; } } return(true); }; if (!m_pgRootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh)) { Debug.Assert(false); return(false); } foreach (PwUuid pwUuid in vUuidsToDelete) { int nIndex = GetCustomIconIndex(pwUuid); if (nIndex >= 0) { m_vCustomIcons.RemoveAt(nIndex); } } return(true); }
public EcasEventType(PwUuid uuidType, string strName, PwIcon pwIcon, EcasParameter[] vParams, EcasEventCompare f) { if((uuidType == null) || (uuidType.EqualsValue(PwUuid.Zero))) throw new ArgumentNullException("uuidType"); if(strName == null) throw new ArgumentNullException("strName"); // if(vParams == null) throw new ArgumentNullException("vParams"); // if(f == null) throw new ArgumentNullException("f"); m_type = uuidType; m_strName = strName; m_pwIcon = pwIcon; m_vParams = (vParams ?? EcasParameter.EmptyArray); m_fn = (f ?? EcasEventCompareTrue); }
/// <summary> /// Assign properties to the current entry based on a template entry. /// </summary> /// <param name="peTemplate">Template entry. Must not be <c>null</c>.</param> /// <param name="bOnlyIfNewer">Only set the properties of the template entry /// if it is newer than the current one.</param> /// <param name="bIncludeHistory">If <c>true</c>, the history will be /// copied, too.</param> public void AssignProperties(PwEntry peTemplate, bool bOnlyIfNewer, bool bIncludeHistory) { Debug.Assert(peTemplate != null); if (peTemplate == null) { throw new ArgumentNullException("peTemplate"); } // Template UUID should be the same as the current one Debug.Assert(m_uuid.EqualsValue(peTemplate.m_uuid)); m_uuid = peTemplate.m_uuid; if (bOnlyIfNewer) { if (peTemplate.m_tLastMod < this.m_tLastMod) { return; } } m_listStrings = peTemplate.m_listStrings; m_listBinaries = peTemplate.m_listBinaries; m_listAutoType = peTemplate.m_listAutoType; if (bIncludeHistory) { m_listHistory = peTemplate.m_listHistory; } m_pwIcon = peTemplate.m_pwIcon; m_pwCustomIconID = peTemplate.m_pwCustomIconID; m_clrForeground = peTemplate.m_clrForeground; m_clrBackground = peTemplate.m_clrBackground; m_tCreation = peTemplate.m_tCreation; m_tLastMod = peTemplate.m_tLastMod; m_tLastAccess = peTemplate.m_tLastAccess; m_tExpire = peTemplate.m_tExpire; m_bExpires = peTemplate.m_bExpires; m_uUsageCount = peTemplate.m_uUsageCount; m_strOverrideUrl = peTemplate.m_strOverrideUrl; }
internal static void GetNeighborItems(List<IStructureItem> vItems, PwUuid pwPivot, Queue<PwUuid> qBefore, Queue<PwUuid> qAfter) { qBefore.Clear(); qAfter.Clear(); // Checks after clearing the queues if(vItems == null) { Debug.Assert(false); return; } // No throw bool bBefore = true; for(int i = 0; i < vItems.Count; ++i) { PwUuid pw = vItems[i].Uuid; if(pw.EqualsValue(pwPivot)) bBefore = false; else if(bBefore) qBefore.Enqueue(pw); else qAfter.Enqueue(pw); } Debug.Assert(bBefore == false); }
public bool EqualsEntry(PwEntry pe, PwCompareOptions pwOpt, MemProtCmpMode mpCmpStr) { if (pe == null) { Debug.Assert(false); return(false); } bool bNeEqStd = ((pwOpt & PwCompareOptions.NullEmptyEquivStd) != PwCompareOptions.None); bool bIgnoreLastAccess = ((pwOpt & PwCompareOptions.IgnoreLastAccess) != PwCompareOptions.None); bool bIgnoreLastMod = ((pwOpt & PwCompareOptions.IgnoreLastMod) != PwCompareOptions.None); if (!m_uuid.EqualsValue(pe.m_uuid)) { return(false); } if ((pwOpt & PwCompareOptions.IgnoreParentGroup) == PwCompareOptions.None) { if (m_pParentGroup != pe.m_pParentGroup) { return(false); } if (!bIgnoreLastMod && (m_tParentGroupLastMod != pe.m_tParentGroupLastMod)) { return(false); } } if (!m_listStrings.EqualsDictionary(pe.m_listStrings, pwOpt, mpCmpStr)) { return(false); } if (!m_listBinaries.EqualsDictionary(pe.m_listBinaries)) { return(false); } if (!m_listAutoType.Equals(pe.m_listAutoType)) { return(false); } if ((pwOpt & PwCompareOptions.IgnoreHistory) == PwCompareOptions.None) { bool bIgnoreLastBackup = ((pwOpt & PwCompareOptions.IgnoreLastBackup) != PwCompareOptions.None); if (!bIgnoreLastBackup && (m_listHistory.UCount != pe.m_listHistory.UCount)) { return(false); } if (bIgnoreLastBackup && (m_listHistory.UCount == 0)) { Debug.Assert(false); return(false); } if (bIgnoreLastBackup && ((m_listHistory.UCount - 1) != pe.m_listHistory.UCount)) { return(false); } PwCompareOptions cmpSub = PwCompareOptions.IgnoreParentGroup; if (bNeEqStd) { cmpSub |= PwCompareOptions.NullEmptyEquivStd; } if (bIgnoreLastMod) { cmpSub |= PwCompareOptions.IgnoreLastMod; } if (bIgnoreLastAccess) { cmpSub |= PwCompareOptions.IgnoreLastAccess; } for (uint uHist = 0; uHist < pe.m_listHistory.UCount; ++uHist) { if (!m_listHistory.GetAt(uHist).EqualsEntry(pe.m_listHistory.GetAt( uHist), cmpSub, MemProtCmpMode.None)) { return(false); } } } if (m_pwIcon != pe.m_pwIcon) { return(false); } if (!m_pwCustomIconID.EqualsValue(pe.m_pwCustomIconID)) { return(false); } if (m_clrForeground != pe.m_clrForeground) { return(false); } if (m_clrBackground != pe.m_clrBackground) { return(false); } if (m_tCreation != pe.m_tCreation) { return(false); } if (!bIgnoreLastMod && (m_tLastMod != pe.m_tLastMod)) { return(false); } if (!bIgnoreLastAccess && (m_tLastAccess != pe.m_tLastAccess)) { return(false); } if (m_tExpire != pe.m_tExpire) { return(false); } if (m_bExpires != pe.m_bExpires) { return(false); } if (!bIgnoreLastAccess && (m_uUsageCount != pe.m_uUsageCount)) { return(false); } if (m_strOverrideUrl != pe.m_strOverrideUrl) { return(false); } if (m_vTags.Count != pe.m_vTags.Count) { return(false); } for (int iTag = 0; iTag < m_vTags.Count; ++iTag) { if (m_vTags[iTag] != pe.m_vTags[iTag]) { return(false); } } return(true); }
public bool EqualsEntry(PwEntry pe, bool bIgnoreParentGroup, bool bIgnoreLastMod, bool bIgnoreLastAccess, bool bIgnoreHistory, bool bIgnoreThisLastBackup) { if (pe == null) { Debug.Assert(false); return(false); } if (!m_uuid.EqualsValue(pe.m_uuid)) { return(false); } if (!bIgnoreParentGroup) { if (m_pParentGroup != pe.m_pParentGroup) { return(false); } if (!bIgnoreLastMod && (m_tParentGroupLastMod != pe.m_tParentGroupLastMod)) { return(false); } } if (!m_listStrings.EqualsDictionary(pe.m_listStrings)) { return(false); } if (!m_listBinaries.EqualsDictionary(pe.m_listBinaries)) { return(false); } if (!m_listAutoType.EqualsConfig(pe.m_listAutoType)) { return(false); } if (!bIgnoreHistory) { if (!bIgnoreThisLastBackup && (m_listHistory.UCount != pe.m_listHistory.UCount)) { return(false); } if (bIgnoreThisLastBackup && (m_listHistory.UCount == 0)) { Debug.Assert(false); return(false); } if (bIgnoreThisLastBackup && ((m_listHistory.UCount - 1) != pe.m_listHistory.UCount)) { return(false); } for (uint uHist = 0; uHist < pe.m_listHistory.UCount; ++uHist) { if (!m_listHistory.GetAt(uHist).EqualsEntry(pe.m_listHistory.GetAt( uHist), true, bIgnoreLastMod, bIgnoreLastAccess, false, false)) { return(false); } } } if (m_pwIcon != pe.m_pwIcon) { return(false); } if (!m_pwCustomIconID.EqualsValue(pe.m_pwCustomIconID)) { return(false); } if (m_clrForeground != pe.m_clrForeground) { return(false); } if (m_clrBackground != pe.m_clrBackground) { return(false); } if (m_tCreation != pe.m_tCreation) { return(false); } if (!bIgnoreLastMod && (m_tLastMod != pe.m_tLastMod)) { return(false); } if (!bIgnoreLastAccess && (m_tLastAccess != pe.m_tLastAccess)) { return(false); } if (m_tExpire != pe.m_tExpire) { return(false); } if (m_bExpires != pe.m_bExpires) { return(false); } if (!bIgnoreLastAccess && (m_uUsageCount != pe.m_uUsageCount)) { return(false); } if (m_strOverrideUrl != pe.m_strOverrideUrl) { return(false); } return(true); }