Adding WithIdentity() content metadata helper to add IdentityPart in migrations and changing affected code to use this

This commit is contained in:
Lombiq
2016-01-04 19:09:00 +01:00
parent fde4c32aff
commit aaced541e3
19 changed files with 64 additions and 42 deletions

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.ContentManagement.MetaData.Builders;
namespace Orchard.ContentManagement.MetaData {
public static class CommonMetaDataExtensions {
/// <summary>
/// Adds IdentityPart to the content type.
/// </summary>
/// <returns>The ContentTypeDefinitionBuilder object on which this method is called.</returns>
public static ContentTypeDefinitionBuilder WithIdentity(this ContentTypeDefinitionBuilder builder) {
return builder.WithPart("IdentityPart");
}
}
}

View File

@@ -20,7 +20,7 @@ namespace Orchard.Core.Navigation {
ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg
.WithPart("MenuPart") .WithPart("MenuPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("CommonPart") .WithPart("CommonPart")
.DisplayedAs("Custom Link") .DisplayedAs("Custom Link")
.WithSetting("Description", "Represents a simple custom link with a text and an url.") .WithSetting("Description", "Represents a simple custom link with a text and an url.")
@@ -34,7 +34,7 @@ namespace Orchard.Core.Navigation {
ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithPart("MenuWidgetPart") .WithPart("MenuWidgetPart")
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")
@@ -52,7 +52,7 @@ namespace Orchard.Core.Navigation {
.WithPart("MenuPart") .WithPart("MenuPart")
.WithPart("BodyPart") .WithPart("BodyPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.DisplayedAs("Html Menu Item") .DisplayedAs("Html Menu Item")
.WithSetting("Description", "Renders some custom HTML in the menu.") .WithSetting("Description", "Renders some custom HTML in the menu.")
.WithSetting("BodyPartSettings.FlavorDefault", "html") .WithSetting("BodyPartSettings.FlavorDefault", "html")
@@ -92,7 +92,7 @@ namespace Orchard.Core.Navigation {
ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg
.WithPart("MenuPart") .WithPart("MenuPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.DisplayedAs("Custom Link") .DisplayedAs("Custom Link")
.WithSetting("Description", "Represents a simple custom link with a text and an url.") .WithSetting("Description", "Represents a simple custom link with a text and an url.")
.WithSetting("Stereotype", "MenuItem") // because we declare a new stereotype, the Shape MenuItem_Edit is needed .WithSetting("Stereotype", "MenuItem") // because we declare a new stereotype, the Shape MenuItem_Edit is needed
@@ -115,7 +115,7 @@ namespace Orchard.Core.Navigation {
ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg ContentDefinitionManager.AlterTypeDefinition("MenuWidget", cfg => cfg
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithPart("MenuWidgetPart") .WithPart("MenuWidgetPart")
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")
@@ -130,7 +130,7 @@ namespace Orchard.Core.Navigation {
.WithPart("MenuPart") .WithPart("MenuPart")
.WithPart("BodyPart") .WithPart("BodyPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.DisplayedAs("Html Menu Item") .DisplayedAs("Html Menu Item")
.WithSetting("Description", "Renders some custom HTML in the menu.") .WithSetting("Description", "Renders some custom HTML in the menu.")
.WithSetting("BodyPartSettings.FlavorDefault", "html") .WithSetting("BodyPartSettings.FlavorDefault", "html")
@@ -172,7 +172,7 @@ namespace Orchard.Core.Navigation {
public int UpdateFrom5() { public int UpdateFrom5() {
ContentDefinitionManager.AlterTypeDefinition("Menu", cfg => cfg ContentDefinitionManager.AlterTypeDefinition("Menu", cfg => cfg
.WithPart("IdentityPart") .WithIdentity()
); );
return 6; return 6;

View File

@@ -77,6 +77,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Common\Controllers\ErrorController.cs" /> <Compile Include="Common\Controllers\ErrorController.cs" />
<Compile Include="Common\DateEditor\DateEditorSettings.cs" /> <Compile Include="Common\DateEditor\DateEditorSettings.cs" />
<Compile Include="Common\Extensions\CommonMetaDataExtensions.cs" />
<Compile Include="Common\OwnerEditor\OwnerEditorSettings.cs" /> <Compile Include="Common\OwnerEditor\OwnerEditorSettings.cs" />
<Compile Include="Common\OwnerEditor\OwnerEditorDriver.cs" /> <Compile Include="Common\OwnerEditor\OwnerEditorDriver.cs" />
<Compile Include="Common\DateEditor\DateEditorDriver.cs" /> <Compile Include="Common\DateEditor\DateEditorDriver.cs" />

View File

@@ -66,7 +66,7 @@ namespace Orchard.Azure.MediaServices {
ContentDefinitionManager.AlterTypeDefinition("CloudVideo", type => type ContentDefinitionManager.AlterTypeDefinition("CloudVideo", type => type
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("MediaPart") .WithPart("MediaPart")
.WithPart("TitlePart") .WithPart("TitlePart")
.WithPart("PublishLaterPart") .WithPart("PublishLaterPart")

View File

@@ -80,7 +80,7 @@ namespace Orchard.Blogs {
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")
.WithPart("IdentityPart") .WithIdentity()
); );
return 7; return 7;
@@ -134,12 +134,12 @@ namespace Orchard.Blogs {
public int UpdateFrom6() { public int UpdateFrom6() {
ContentDefinitionManager.AlterTypeDefinition("RecentBlogPosts", ContentDefinitionManager.AlterTypeDefinition("RecentBlogPosts",
cfg => cfg cfg => cfg
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("BlogArchives", ContentDefinitionManager.AlterTypeDefinition("BlogArchives",
cfg => cfg cfg => cfg
.WithPart("IdentityPart") .WithIdentity()
); );
return 7; return 7;

View File

@@ -56,7 +56,7 @@ namespace Orchard.Comments {
p => p p => p
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")
.WithSetting("DateEditorSettings.ShowDateEditor", "false")) .WithSetting("DateEditorSettings.ShowDateEditor", "false"))
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("Blog", ContentDefinitionManager.AlterTypeDefinition("Blog",
@@ -82,7 +82,7 @@ namespace Orchard.Comments {
} }
public int UpdateFrom1() { public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("Comment", cfg => cfg.WithPart("IdentityPart")); ContentDefinitionManager.AlterTypeDefinition("Comment", cfg => cfg.WithIdentity());
return 2; return 2;
} }

View File

@@ -16,7 +16,7 @@ namespace Orchard.ContentPicker {
ContentDefinitionManager.AlterTypeDefinition("ContentMenuItem", cfg => cfg ContentDefinitionManager.AlterTypeDefinition("ContentMenuItem", cfg => cfg
.WithPart("MenuPart") .WithPart("MenuPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("ContentMenuItemPart") .WithPart("ContentMenuItemPart")
.DisplayedAs("Content Menu Item") .DisplayedAs("Content Menu Item")
.WithSetting("Description", "Adds a Content Item to the menu.") .WithSetting("Description", "Adds a Content Item to the menu.")

View File

@@ -37,7 +37,7 @@ namespace Orchard.CustomForms {
cfg => cfg cfg => cfg
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("CustomFormPart") .WithPart("CustomFormPart")
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")
); );

View File

@@ -7,7 +7,7 @@ namespace Orchard.Dashboards {
public int Create() { public int Create() {
ContentDefinitionManager.AlterTypeDefinition("Dashboard", type => type ContentDefinitionManager.AlterTypeDefinition("Dashboard", type => type
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("TitlePart") .WithPart("TitlePart")
.WithPart("LayoutPart", p => p .WithPart("LayoutPart", p => p
.WithSetting("LayoutTypePartSettings.DefaultLayoutData", DefaultDashboardSelector.DefaultLayout))); .WithSetting("LayoutTypePartSettings.DefaultLayoutData", DefaultDashboardSelector.DefaultLayout)));

View File

@@ -108,7 +108,7 @@ namespace Orchard.DynamicForms {
public int UpdateFrom2() { public int UpdateFrom2() {
ContentDefinitionManager.AlterTypeDefinition("FormWidget", type => type ContentDefinitionManager.AlterTypeDefinition("FormWidget", type => type
.WithPart("IdentityPart")); .WithIdentity());
return 3; return 3;
} }

View File

@@ -29,7 +29,7 @@ namespace Orchard.Layouts {
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")
.WithSetting("DateEditorSettings.ShowDateEditor", "false")) .WithSetting("DateEditorSettings.ShowDateEditor", "false"))
.WithPart("TitlePart") .WithPart("TitlePart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("LayoutPart", p => p .WithPart("LayoutPart", p => p
.WithSetting("LayoutTypePartSettings.IsTemplate", "True")) .WithSetting("LayoutTypePartSettings.IsTemplate", "True"))
.DisplayedAs("Layout") .DisplayedAs("Layout")
@@ -39,7 +39,7 @@ namespace Orchard.Layouts {
.WithPart("CommonPart", p => p .WithPart("CommonPart", p => p
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")
.WithSetting("DateEditorSettings.ShowDateEditor", "false")) .WithSetting("DateEditorSettings.ShowDateEditor", "false"))
.WithPart("IdentityPart") .WithIdentity()
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithPart("LayoutPart") .WithPart("LayoutPart")
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")
@@ -72,7 +72,7 @@ namespace Orchard.Layouts {
public int UpdateFrom2() { public int UpdateFrom2() {
ContentDefinitionManager.AlterTypeDefinition("Layout", type => type ContentDefinitionManager.AlterTypeDefinition("Layout", type => type
.WithPart("IdentityPart")); .WithIdentity());
return 3; return 3;
} }
@@ -83,7 +83,7 @@ namespace Orchard.Layouts {
.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false") .WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")
.WithSetting("DateEditorSettings.ShowDateEditor", "false")) .WithSetting("DateEditorSettings.ShowDateEditor", "false"))
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("ElementWrapperPart", p => p .WithPart("ElementWrapperPart", p => p
.WithSetting("ElementWrapperPartSettings.ElementTypeName", elementTypeName)) .WithSetting("ElementWrapperPartSettings.ElementTypeName", elementTypeName))
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")

View File

@@ -59,41 +59,41 @@ namespace Orchard.MediaLibrary {
.DisplayedAs("Image") .DisplayedAs("Image")
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
.AsImage() .AsImage()
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("VectorImage", td => td ContentDefinitionManager.AlterTypeDefinition("VectorImage", td => td
.DisplayedAs("Vector Image") .DisplayedAs("Vector Image")
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
.AsVectorImage() .AsVectorImage()
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("Video", td => td ContentDefinitionManager.AlterTypeDefinition("Video", td => td
.DisplayedAs("Video") .DisplayedAs("Video")
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
.AsVideo() .AsVideo()
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("Audio", td => td ContentDefinitionManager.AlterTypeDefinition("Audio", td => td
.DisplayedAs("Audio") .DisplayedAs("Audio")
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
.AsAudio() .AsAudio()
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("Document", td => td ContentDefinitionManager.AlterTypeDefinition("Document", td => td
.DisplayedAs("Document") .DisplayedAs("Document")
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
.AsDocument() .AsDocument()
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td
.DisplayedAs("External Media") .DisplayedAs("External Media")
.WithSetting("Stereotype", "Media") .WithSetting("Stereotype", "Media")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("MediaPart") .WithPart("MediaPart")
.WithPart("OEmbedPart") .WithPart("OEmbedPart")
@@ -105,23 +105,23 @@ namespace Orchard.MediaLibrary {
public int UpdateFrom2() { public int UpdateFrom2() {
ContentDefinitionManager.AlterTypeDefinition("Image", td => td ContentDefinitionManager.AlterTypeDefinition("Image", td => td
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("Video", td => td ContentDefinitionManager.AlterTypeDefinition("Video", td => td
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("Audio", td => td ContentDefinitionManager.AlterTypeDefinition("Audio", td => td
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("Document", td => td ContentDefinitionManager.AlterTypeDefinition("Document", td => td
.WithPart("IdentityPart") .WithIdentity()
); );
ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td ContentDefinitionManager.AlterTypeDefinition("OEmbed", td => td
.WithPart("IdentityPart") .WithIdentity()
); );
return 3; return 3;
@@ -200,7 +200,7 @@ namespace Orchard.MediaLibrary {
.DisplayedAs("Vector Image") .DisplayedAs("Vector Image")
.WithSetting("Stereotype", "Media") .WithSetting("Stereotype", "Media")
.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True") .WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", "True")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("MediaPart") .WithPart("MediaPart")
.WithPart("VectorImagePart") .WithPart("VectorImagePart")

View File

@@ -14,7 +14,7 @@ namespace Orchard.MediaProcessing {
cfg => cfg cfg => cfg
.WithPart("ImageProfilePart") .WithPart("ImageProfilePart")
.WithPart("CommonPart", p => p.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false")) .WithPart("CommonPart", p => p.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false"))
.WithPart("IdentityPart") .WithIdentity()
); );
SchemaBuilder.CreateTable("FilterRecord", SchemaBuilder.CreateTable("FilterRecord",

View File

@@ -64,7 +64,7 @@ namespace Orchard.Projections {
cfg => cfg cfg => cfg
.WithPart("QueryPart") .WithPart("QueryPart")
.WithPart("TitlePart") .WithPart("TitlePart")
.WithPart("IdentityPart") .WithIdentity()
); );
SchemaBuilder.CreateTable("QueryPartRecord", SchemaBuilder.CreateTable("QueryPartRecord",
@@ -179,7 +179,7 @@ namespace Orchard.Projections {
cfg => cfg cfg => cfg
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("ProjectionPart") .WithPart("ProjectionPart")
.WithSetting("Stereotype", "Widget") .WithSetting("Stereotype", "Widget")
); );
@@ -277,7 +277,7 @@ namespace Orchard.Projections {
public int UpdateFrom3() { public int UpdateFrom3() {
ContentDefinitionManager.AlterTypeDefinition("NavigationQueryMenuItem", ContentDefinitionManager.AlterTypeDefinition("NavigationQueryMenuItem",
cfg => cfg cfg => cfg
.WithPart("IdentityPart") .WithIdentity()
); );
return 4; return 4;

View File

@@ -27,7 +27,7 @@ namespace Orchard.Search {
public int UpdateFrom2() { public int UpdateFrom2() {
ContentDefinitionManager.AlterTypeDefinition("SearchForm", ContentDefinitionManager.AlterTypeDefinition("SearchForm",
cfg => cfg.WithPart("IdentityPart")); cfg => cfg.WithIdentity());
return 3; return 3;
} }

View File

@@ -101,6 +101,10 @@
<Name>Orchard.Framework</Name> <Name>Orchard.Framework</Name>
<Private>false</Private> <Private>false</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839c-39fc-4ceb-a5af-89ca7e87119f}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.MediaLibrary\Orchard.MediaLibrary.csproj"> <ProjectReference Include="..\Orchard.MediaLibrary\Orchard.MediaLibrary.csproj">
<Project>{73a7688a-5bd3-4f7e-adfa-ce36c5a10e3b}</Project> <Project>{73a7688a-5bd3-4f7e-adfa-ce36c5a10e3b}</Project>
<Name>Orchard.MediaLibrary</Name> <Name>Orchard.MediaLibrary</Name>

View File

@@ -12,7 +12,7 @@ namespace Orchard.Templates {
ContentDefinitionManager.AlterTypeDefinition("Template", type => type ContentDefinitionManager.AlterTypeDefinition("Template", type => type
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("IdentityPart") .WithIdentity()
.WithPart("TitlePart") .WithPart("TitlePart")
.WithPart("ShapePart") .WithPart("ShapePart")
.Draftable()); .Draftable());

View File

@@ -25,8 +25,8 @@ namespace Orchard.ContentManagement.MetaData {
return builder return builder
.WithPart("CommonPart") .WithPart("CommonPart")
.WithPart("WidgetPart") .WithPart("WidgetPart")
.WithPart("IdentityPart") .WithSetting("Stereotype", "Widget")
.WithSetting("Stereotype", "Widget"); .WithIdentity();
} }
} }
} }

View File

@@ -44,7 +44,7 @@ namespace Orchard.Widgets {
} }
public int UpdateFrom1() { public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget", cfg => cfg.WithPart("IdentityPart")); ContentDefinitionManager.AlterTypeDefinition("HtmlWidget", cfg => cfg.WithIdentity());
return 2; return 2;
} }