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


C# ContentItem.Weld方法代码示例

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


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

示例1: SetupRoutePart

        private void SetupRoutePart(PackagePart packagePartToMapTo) {
            var contentItem = new ContentItem { ContentType = "Package" };
            var routePart = new AutoroutePart {Record = new AutoroutePartRecord()};
            contentItem.Weld(routePart);
            contentItem.Weld(packagePartToMapTo);

        }
开发者ID:NickAndersonX,项目名称:xodb,代码行数:7,代码来源:MapPublishedPackageToPackagePartTester.cs

示例2: ContentItemPropertyOnPartRootsYou

        public void ContentItemPropertyOnPartRootsYou() {
            var contentItem = new ContentItem();
            var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
            var anotherPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("AnotherPart"), new SettingsDictionary()) };
            contentItem.Weld(testingPart);
            contentItem.Weld(anotherPart);

            dynamic contentItemDynamic = contentItem;
            dynamic testingPartDynamic  = contentItemDynamic.TestingPart;
            dynamic anotherPartDynamic  = contentItemDynamic.AnotherPart;

            dynamic contentItemDynamic1  = testingPartDynamic.ContentItem;
            dynamic contentItemDynamic2  = anotherPartDynamic.ContentItem;

            Assert.That((object)contentItemDynamic1, Is.SameAs(contentItem));
            Assert.That((object)contentItemDynamic2, Is.SameAs(contentItem));
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:17,代码来源:DynamicContentItemTests.cs

示例3: ContentPartsAlsoProjectPartNamesAsProperties

        public void ContentPartsAlsoProjectPartNamesAsProperties() {
            var contentItem = new ContentItem();
            var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
            var anotherPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("AnotherPart"), new SettingsDictionary()) };
            contentItem.Weld(testingPart);
            contentItem.Weld(anotherPart);

            dynamic contentItemDynamic = contentItem;
            dynamic testingPartDynamic  = contentItemDynamic.TestingPart;
            dynamic anotherPartDynamic  = contentItemDynamic.AnotherPart;
            dynamic testingPartDynamic2  = testingPartDynamic.TestingPart;
            dynamic anotherPartDynamic2  = testingPartDynamic.AnotherPart;

            Assert.That((object)testingPartDynamic, Is.SameAs(testingPart));
            Assert.That((object)anotherPartDynamic, Is.SameAs(anotherPart));
            Assert.That((object)testingPartDynamic2, Is.SameAs(testingPart));
            Assert.That((object)anotherPartDynamic2, Is.SameAs(anotherPart));
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:18,代码来源:DynamicContentItemTests.cs

示例4: ContentShouldOnlyContainParts

        public void ContentShouldOnlyContainParts()
        {
            var contentItem = new ContentItem();
            contentItem.Weld<MyPart>();
            contentItem.Alter<MyPart>(x => x.Text = "test");

            var json = JsonConvert.SerializeObject(contentItem);

            Assert.Contains(@"""MyPart"":{""Text"":""test""}", json);
        }
开发者ID:zhongzf,项目名称:Brochard,代码行数:10,代码来源:ContentItemTests.cs

示例5: CreateContentItemPart

 private ContentPart CreateContentItemPart() {
     var partDefinition = FooPartDefinition();
     var typeDefinition = new ContentTypeDefinitionBuilder()
         .WithPart(partDefinition, part => { })
         .Build();
     var contentItem = new ContentItem {
         VersionRecord = new ContentItemVersionRecord {
             ContentItemRecord = new ContentItemRecord()
         }
     };
     var contentPart = new ContentPart {
         TypePartDefinition = typeDefinition.Parts.Single()
     };
     contentItem.Weld(contentPart);
     contentItem.Weld(new InfosetPart {
         Infoset = contentItem.Record.Infoset,
         VersionInfoset = contentItem.VersionRecord.Infoset
     });
     return contentPart;
 }
开发者ID:rupertwhitlock,项目名称:IncreasinglyAbsorbing,代码行数:20,代码来源:InfosetFieldStorageProviderTests.cs

示例6: ActualPropertiesTakePriority

        public void ActualPropertiesTakePriority() {
            var contentItem = new ContentItem();
            var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("Parts"), new SettingsDictionary()) };
            contentItem.Weld(testingPart);

            dynamic contentItemDynamic = contentItem;
            dynamic testingPartDynamic  = contentItemDynamic.Parts;


            Assert.That((object)testingPartDynamic, Is.AssignableTo<IEnumerable<ContentPart>>());
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:11,代码来源:DynamicContentItemTests.cs

示例7: ShouldCallRecommendedVersionUpdater

        public void ShouldCallRecommendedVersionUpdater() {
            PackagePart newPackagePart = new PackagePart { Record = new PackagePartRecord(), PackageID = "foo", PackageVersion = "1.0" };
            var contentItem = new ContentItem { ContentType = "Package" };
            contentItem.Weld(newPackagePart);
            PublishedPackage publishedPackage = new PublishedPackage { Id = newPackagePart.PackageID, Version = newPackagePart.PackageVersion };
            _mockedOdataContext.SetupGet(oc => oc.Packages).Returns(new[] { publishedPackage }.AsQueryable());
            _mockedContentManager.Setup(cm => cm.New(It.IsAny<string>())).Returns(contentItem);

            _creator.CreateNewPackagePart(new PackageLogEntry { PackageId = newPackagePart.PackageID, PackageVersion = newPackagePart.PackageVersion});

            _mockedRecommendedVersionUpdater.Verify(rvu => rvu.SetRecommendedVersionFlagsOfOtherPackagesWithSameId(newPackagePart));
        }
开发者ID:NickAndersonX,项目名称:xodb,代码行数:12,代码来源:CreateNewPackagePartTester.cs

示例8: UpdateAsync

        public override async Task<IDisplayResult> UpdateAsync(ContentItem model, IUpdateModel updater)
        {
            var viewModel = new EditContainedPartViewModel();

            if (await updater.TryUpdateModelAsync(viewModel, "ListPart"))
            {
                model.Weld<ContainedPart>();
                model.Alter<ContainedPart>(x => x.ListContentItemId = viewModel.ContainerId);
            }

            return await base.UpdateAsync(model, updater);
        }
开发者ID:MichaelPetrinolis,项目名称:Orchard2,代码行数:12,代码来源:ContainedPartDisplayDriver.cs

示例9: ShouldSerializeParts

        public void ShouldSerializeParts()
        {
            var contentItem = new ContentItem();
            var myPart = new MyPart { Text = "test" };
            contentItem.Weld(myPart);

            var json = JsonConvert.SerializeObject(contentItem);

            var contentItem2 = JsonConvert.DeserializeObject<ContentItem>(json);

            Assert.NotNull(contentItem.Content.MyPart);
            Assert.Equal("test", (string)contentItem.Content.MyPart.Text);
        }
开发者ID:zhongzf,项目名称:Brochard,代码行数:13,代码来源:ContentItemTests.cs

示例10: ShouldAlterPart

        public void ShouldAlterPart()
        {
            var contentItem = new ContentItem();
            contentItem.Weld<MyPart>();
            contentItem.Alter<MyPart>(x => x.Text = "test");

            var json = JsonConvert.SerializeObject(contentItem);

            var contentItem2 = JsonConvert.DeserializeObject<ContentItem>(json);

            Assert.NotNull(contentItem.Content.MyPart);
            Assert.Equal("test", (string)contentItem.Content.MyPart.Text);
        }
开发者ID:zhongzf,项目名称:Brochard,代码行数:13,代码来源:ContentItemTests.cs

示例11: ShouldCreateNewPackagePartWhenNoExistingOrchardVersionsOfPackageExist

        public void ShouldCreateNewPackagePartWhenNoExistingOrchardVersionsOfPackageExist() {
            PackagePart newPackagePart = new PackagePart { Record = new PackagePartRecord(), PackageID = "foo", PackageVersion = "1.0" };
            var contentItem = new ContentItem { ContentType = "Package" };
            contentItem.Weld(newPackagePart);
            PublishedPackage publishedPackage = new PublishedPackage { Id = newPackagePart.PackageID, Version = newPackagePart.PackageVersion };
            _mockedOdataContext.SetupGet(oc => oc.Packages).Returns(new[] { publishedPackage }.AsQueryable());
            _mockedContentManager.Setup(cm => cm.New(It.IsAny<string>())).Returns(contentItem);
            _mockedPackageService.Setup(ps => ps.PackageExists(newPackagePart.PackageID, newPackagePart.PackageVersion, It.IsAny<VersionOptions>())).Returns(false);

            _creator.CreateNewPackagePart(new PackageLogEntry { PackageId = newPackagePart.PackageID, PackageVersion = newPackagePart.PackageVersion });

            _mockedContentManager.Verify(cm => cm.Create(It.IsAny<ContentItem>(), It.IsAny<VersionOptions>()), Times.Once());
        }
开发者ID:NickAndersonX,项目名称:xodb,代码行数:13,代码来源:CreateNewPackagePartTester.cs

示例12: ContentShouldStoreFields

        public void ContentShouldStoreFields()
        {
            var contentItem = new ContentItem();
            contentItem.Weld<MyPart>();
            contentItem.Alter<MyPart>(x => x.Text = "test");
            contentItem.Alter<MyPart>(x =>
            {
                x.Weld<MyField>("myField");
                x.Alter<MyField>("myField", f => f.Value = 123);
            });

            var json = JsonConvert.SerializeObject(contentItem);

            Assert.Contains(@"""MyPart"":{""Text"":""test"",""myField"":{""Value"":123}}", json);
        }
开发者ID:zhongzf,项目名称:Brochard,代码行数:15,代码来源:ContentItemTests.cs

示例13: UpdateAsync

        public override async Task<IDisplayResult> UpdateAsync(ContentItem contentItem, IUpdateModel updater)
        {
            var testContentPart = contentItem.As<TestContentPartA>();

            if (testContentPart == null)
            {
                return null;
            }

            if (await updater.TryUpdateModelAsync(testContentPart, ""))
            {
                if (testContentPart.Line.EndsWith(" "))
                {
                    updater.ModelState.AddModelError(nameof(testContentPart.Line), "Value cannot end with a space");
                }
                else
                {
                    contentItem.Weld(testContentPart);
                }
            }
            
            return Shape("TestContentPartA_Edit", testContentPart).Location("Content");
        }
开发者ID:MichaelPetrinolis,项目名称:Orchard2,代码行数:23,代码来源:TestContentDisplay.cs

示例14: ShouldLogMessageWhenPackagePartAlreadyExists

        public void ShouldLogMessageWhenPackagePartAlreadyExists()
        {
            PackagePart newPackagePart = new PackagePart { Record = new PackagePartRecord(), PackageID = "foo", PackageVersion = "1.0" };
            var contentItem = new ContentItem { ContentType = "Package" };
            contentItem.Weld(newPackagePart);

            PublishedPackage publishedPackage = new PublishedPackage { Id = newPackagePart.PackageID, Version = newPackagePart.PackageVersion };

            _mockedOdataContext.SetupGet(oc => oc.Packages).Returns(new[] { publishedPackage }.AsQueryable());
            _mockedContentManager.Setup(cm => cm.New(It.IsAny<string>())).Returns(contentItem);
            _mockedPackageService.Setup(ps => ps.PackageExists(newPackagePart.PackageID, newPackagePart.PackageVersion, It.IsAny<VersionOptions>()))
                .Returns(true);

            _creator.CreateNewPackagePart(new PackageLogEntry { PackageId = newPackagePart.PackageID, PackageVersion = newPackagePart.PackageVersion });

            _mockedLogger.Verify(l => l.Log(LogLevel.Information, null, It.Is<string>(s => s.Contains("already exists in the gallery")),
                It.IsAny<object[]>()), Times.Once());
        }
开发者ID:NickAndersonX,项目名称:xodb,代码行数:18,代码来源:CreateNewPackagePartTester.cs

示例15: DumpContentItem_DepthSix

        public void DumpContentItem_DepthSix() {
            var contentItem = new ContentItem { ContentType = "TestContentType" };
            var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
            contentItem.Weld(testingPart);

            var objectDumper = new ObjectDumper(6);
            var xElement = objectDumper.Dump(contentItem, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"),
                new JProperty("value", "ContentItem"),
                new JProperty("children", new JArray(
                    new JObject(
                        new JProperty("name", "Id"),
                        new JProperty("value", "0")),
                    new JObject(
                        new JProperty("name", "Version"),
                        new JProperty("value", "0")),
                    new JObject(
                        new JProperty("name", "ContentType"),
                        new JProperty("value", "&quot;TestContentType&quot;")),
                    new JObject(
                        new JProperty("name", "TestingPart"),
                        new JProperty("value", "ContentPart"),
                        new JProperty("children", new JArray(
                            new JObject(
                                new JProperty("name", "Id"),
                                new JProperty("value", "0")),
                            new JObject(
                                new JProperty("name", "TypeDefinition"),
                                new JProperty("value", "null")),
                            new JObject(
                                new JProperty("name", "TypePartDefinition"),
                                new JProperty("value", "ContentTypePartDefinition"),
                                new JProperty("children", new JArray(
                                    new JObject(
                                        new JProperty("name", "PartDefinition"),
                                        new JProperty("value", "ContentPartDefinition"),
                                        new JProperty("children", new JArray(
                                                new JObject(
                                                    new JProperty("name", "Name"),
                                                    new JProperty("value", "&quot;TestingPart&quot;")),
                                                new JObject(
                                                    new JProperty("name", "Fields"),
                                                    new JProperty("value", "ContentPartFieldDefinition[]")),
                                                new JObject(
                                                    new JProperty("name", "Settings"),
                                                    new JProperty("value", "SettingsDictionary"))))),
                                    new JObject(
                                        new JProperty("name", "Settings"),
                                        new JProperty("value", "SettingsDictionary")),
                                    new JObject(
                                        new JProperty("name", "ContentTypeDefinition"),
                                        new JProperty("value", "null"))))),
                            new JObject(
                                new JProperty("name", "PartDefinition"),
                                new JProperty("value", "ContentPartDefinition"),
                                new JProperty("children", new JArray(
                                    new JObject(
                                        new JProperty("name", "Name"),
                                        new JProperty("value", "&quot;TestingPart&quot;")),
                                    new JObject(
                                        new JProperty("name", "Fields"),
                                        new JProperty("value", "ContentPartFieldDefinition[]")),
                                    new JObject(
                                        new JProperty("name", "Settings"),
                                        new JProperty("value", "SettingsDictionary"))))),
                            new JObject(
                                new JProperty("name", "Settings"),
                                new JProperty("value", "SettingsDictionary")),
                            new JObject(
                                new JProperty("name", "Fields"),
                                new JProperty("value", "List&lt;ContentField&gt;"))))))));

            ComparareJsonObject(jObject, json);
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:80,代码来源:ObjectDumperTests.cs


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