本文整理汇总了C#中PwEntry.AssignProperties方法的典型用法代码示例。如果您正苦于以下问题:C# PwEntry.AssignProperties方法的具体用法?C# PwEntry.AssignProperties怎么用?C# PwEntry.AssignProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PwEntry
的用法示例。
在下文中一共展示了PwEntry.AssignProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeIn
/// <summary>
/// Synchronize the current database with another one.
/// </summary>
/// <param name="pwSource">Input database to synchronize with. This input
/// database is used to update the current one, but is not modified! You
/// must copy the current object if you want a second instance of the
/// synchronized database. The input database must not be seen as valid
/// database any more after calling <c>Synchronize</c>.</param>
/// <param name="mm">Merge method.</param>
public void MergeIn(PwDatabase pwSource, PwMergeMethod mm)
{
if(mm == PwMergeMethod.CreateNewUuids)
{
pwSource.RootGroup.CreateNewItemUuids(true, true, true);
}
GroupHandler gh = delegate(PwGroup pg)
{
if(pg == pwSource.m_pgRootGroup) return true;
PwGroup pgLocal = m_pgRootGroup.FindGroup(pg.Uuid, true);
if(pgLocal == null)
{
PwGroup pgSourceParent = pg.ParentGroup;
PwGroup pgLocalContainer;
if(pgSourceParent == pwSource.m_pgRootGroup)
pgLocalContainer = m_pgRootGroup;
else
pgLocalContainer = m_pgRootGroup.FindGroup(pgSourceParent.Uuid, true);
Debug.Assert(pgLocalContainer != null);
PwGroup pgNew = new PwGroup();
pgNew.Uuid = pg.Uuid;
pgNew.AssignProperties(pg, false);
pgLocalContainer.AddGroup(pgNew, true);
}
else // pgLocal != null
{
Debug.Assert(mm != PwMergeMethod.CreateNewUuids);
if(mm == PwMergeMethod.OverwriteExisting)
pgLocal.AssignProperties(pg, false);
else if((mm == PwMergeMethod.OverwriteIfNewer) ||
(mm == PwMergeMethod.Synchronize))
{
pgLocal.AssignProperties(pg, true);
}
// else if(mm == PwMergeMethod.KeepExisting) ...
}
return true;
};
EntryHandler eh = delegate(PwEntry pe)
{
PwEntry peLocal = m_pgRootGroup.FindEntry(pe.Uuid, true);
if(peLocal == null)
{
PwGroup pgSourceParent = pe.ParentGroup;
PwGroup pgLocalContainer;
if(pgSourceParent == pwSource.m_pgRootGroup)
pgLocalContainer = m_pgRootGroup;
else
pgLocalContainer = m_pgRootGroup.FindGroup(pgSourceParent.Uuid, true);
Debug.Assert(pgLocalContainer != null);
PwEntry peNew = new PwEntry(false, false);
peNew.Uuid = pe.Uuid;
peNew.AssignProperties(pe, false, true);
pgLocalContainer.AddEntry(peNew, true);
}
else // peLocal == null
{
Debug.Assert(mm != PwMergeMethod.CreateNewUuids);
if(mm == PwMergeMethod.OverwriteExisting)
peLocal.AssignProperties(pe, false, true);
else if((mm == PwMergeMethod.OverwriteIfNewer) ||
(mm == PwMergeMethod.Synchronize))
{
peLocal.AssignProperties(pe, true, true);
}
// else if(mm == PwMergeMethod.KeepExisting) ...
}
return true;
};
if(!pwSource.RootGroup.TraverseTree(TraversalMethod.PreOrder, gh, eh))
throw new InvalidOperationException();
if(mm == PwMergeMethod.Synchronize)
{
ApplyDeletions(pwSource.m_vDeletedObjects, true);
ApplyDeletions(m_vDeletedObjects, false);
}
}