当前位置: 首页>>代码示例>>C#>>正文


C# PwGroup.AssignProperties方法代码示例

本文整理汇总了C#中PwGroup.AssignProperties方法的典型用法代码示例。如果您正苦于以下问题:C# PwGroup.AssignProperties方法的具体用法?C# PwGroup.AssignProperties怎么用?C# PwGroup.AssignProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PwGroup的用法示例。


在下文中一共展示了PwGroup.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);
            }
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:97,代码来源:PwDatabase.cs


注:本文中的PwGroup.AssignProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。