/// <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> /// <param name="bAssignLocationChanged">If <c>true</c>, the /// <c>LocationChanged</c> property is copied, otherwise not.</param> public void AssignProperties(PwEntry peTemplate, bool bOnlyIfNewer, bool bIncludeHistory, bool bAssignLocationChanged) { if (peTemplate == null) { Debug.Assert(false); throw new ArgumentNullException("peTemplate"); } if (bOnlyIfNewer && (TimeUtil.Compare(peTemplate.m_tLastMod, m_tLastMod, true) < 0)) { return; } // Template UUID should be the same as the current one Debug.Assert(m_uuid.Equals(peTemplate.m_uuid)); m_uuid = peTemplate.m_uuid; if (bAssignLocationChanged) { m_tParentGroupLastMod = peTemplate.m_tParentGroupLastMod; m_puPrevParentGroup = peTemplate.m_puPrevParentGroup; } m_dStrings = peTemplate.m_dStrings.CloneDeep(); m_dBinaries = peTemplate.m_dBinaries.CloneDeep(); m_cfgAutoType = peTemplate.m_cfgAutoType.CloneDeep(); if (bIncludeHistory) { m_lHistory = peTemplate.m_lHistory.CloneDeep(); } m_pwIcon = peTemplate.m_pwIcon; m_puCustomIcon = peTemplate.m_puCustomIcon; // Immutable 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; m_bQualityCheck = peTemplate.m_bQualityCheck; m_lTags = new List <string>(peTemplate.m_lTags); m_dCustomData = peTemplate.m_dCustomData.CloneDeep(); }
/// <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> /// <param name="bAssignLocationChanged"> /// If <c>true</c>, the /// <c>LocationChanged</c> property is copied, otherwise not. /// </param> public void AssignProperties(PwEntry peTemplate, bool bOnlyIfNewer, bool bIncludeHistory, bool bAssignLocationChanged) { Debug.Assert(peTemplate != null); if (peTemplate == null) { throw new ArgumentNullException("peTemplate"); } if (bOnlyIfNewer && (TimeUtil.Compare(peTemplate.m_tLastMod, this.m_tLastMod, true) < 0)) { return; } // Template UUID should be the same as the current one Debug.Assert(this.m_uuid.Equals(peTemplate.m_uuid)); this.m_uuid = peTemplate.m_uuid; if (bAssignLocationChanged) { this.m_tParentGroupLastMod = peTemplate.m_tParentGroupLastMod; } this.m_listStrings = peTemplate.m_listStrings; this.m_listBinaries = peTemplate.m_listBinaries; this.m_listAutoType = peTemplate.m_listAutoType; if (bIncludeHistory) { this.m_listHistory = peTemplate.m_listHistory; } this.m_pwIcon = peTemplate.m_pwIcon; this.m_pwCustomIconID = peTemplate.m_pwCustomIconID; // Immutable this.m_clrForeground = peTemplate.m_clrForeground; this.m_clrBackground = peTemplate.m_clrBackground; this.m_tCreation = peTemplate.m_tCreation; this.m_tLastMod = peTemplate.m_tLastMod; this.m_tLastAccess = peTemplate.m_tLastAccess; this.m_tExpire = peTemplate.m_tExpire; this.m_bExpires = peTemplate.m_bExpires; this.m_uUsageCount = peTemplate.m_uUsageCount; this.m_strOverrideUrl = peTemplate.m_strOverrideUrl; this.m_vTags = new List <string>(peTemplate.m_vTags); }
private void RemoveOldestBackup() { DateTime dtMin = TimeUtil.SafeMaxValueUtc; uint idxRemove = uint.MaxValue; for(uint u = 0; u < m_listHistory.UCount; ++u) { PwEntry pe = m_listHistory.GetAt(u); if(TimeUtil.Compare(pe.LastModificationTime, dtMin, true) < 0) { idxRemove = u; dtMin = pe.LastModificationTime; } } if(idxRemove != uint.MaxValue) m_listHistory.RemoveAt(idxRemove); }