當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。