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


C# Revision.CopyToNewRevision方法代码示例

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


在下文中一共展示了Revision.CopyToNewRevision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompositeEntity_ReSaves

        public void CompositeEntity_ReSaves()
        {
            // Arrange
            var childSchema = CreateAndSaveCompositeSchema(AttributeTypeRegistry, ProviderSetup);
            CompositeEntitySchema merged = null;
            var groupUnitFactory = new GroupUnitFactory(ProviderSetup, childSchema.Id.ToUri(), FakeHiveCmsManager.CreateFakeRepositoryContext(ProviderSetup.FrameworkContext));
            using (var uow = groupUnitFactory.Create())
            {
                merged = uow.Repositories.Schemas.GetComposite<EntitySchema>(childSchema.Id);
            }

            List<TypedAttribute> attribs;
            var entity = MockCompositeEntity(merged, out attribs);
            AssignFakeIdsIfPassthrough(ProviderSetup.ProviderMetadata, entity);

            Assert.That(entity.Attributes.Count, Is.EqualTo(attribs.Count));

            var firstRevision = new Revision<TypedEntity>(entity);

            using (var uow = groupUnitFactory.Create())
            {
                uow.Repositories.Revisions.AddOrUpdate(firstRevision);
                uow.Complete();
            }

            PostWriteCallback.Invoke();

            // Edit the data and resave
            var secondRevision = firstRevision.CopyToNewRevision(FixedStatusTypes.Published);
            secondRevision.Item.Attributes.Last().DynamicValue = "changed";
            secondRevision.Item.Attributes.ForEach(x => x.Id = HiveId.Empty);

            using (var uow = groupUnitFactory.Create())
            {
                uow.Repositories.Revisions.AddOrUpdate(secondRevision);
                uow.Complete();
            }

            PostWriteCallback.Invoke();

            // Load the data again to ensure these attributes are still "inherited"
            using (var uow = groupUnitFactory.Create())
            {
                var reloaded = uow.Repositories.Get<TypedEntity>(entity.Id);
                Assert.That(reloaded.EntitySchema.Id.Value, Is.EqualTo(childSchema.Id.Value));
                Assert.That(reloaded.Attributes.Count, Is.EqualTo(attribs.Count));
                Assert.That(reloaded.Attributes.Select(x => x.AttributeDefinition), Has.Some.TypeOf<InheritedAttributeDefinition>());
            }
        }
开发者ID:paulsuart,项目名称:rebelcmsxu5,代码行数:49,代码来源:AbstractProviderTests.cs


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