本文整理匯總了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);
}
示例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));
}
示例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));
}
示例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);
}
示例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;
}
示例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>>());
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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");
}
示例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());
}
示例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", ""TestContentType"")),
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", ""TestingPart"")),
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", ""TestingPart"")),
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<ContentField>"))))))));
ComparareJsonObject(jObject, json);
}