Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/align-namespaces

# Conflicts:
#	src/Umbraco.Core/IO/ViewHelper.cs
#	src/Umbraco.Core/Models/ContentModel.cs
#	src/Umbraco.Core/Models/ContentModelOfTContent.cs
#	src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/TemplateRepositoryTest.cs
#	src/Umbraco.Tests.UnitTests/Umbraco.Core/Templates/ViewHelperTests.cs
#	src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/Views/UmbracoViewPageTests.cs
#	src/Umbraco.Web.Common/ApplicationModels/BackOfficeApplicationModelProvider.cs
#	src/Umbraco.Web.Common/ApplicationModels/BackOfficeIdentityCultureConvention.cs
#	src/Umbraco.Web.Common/ApplicationModels/UmbracoApiBehaviorApplicationModelProvider.cs
#	src/Umbraco.Web.Common/ApplicationModels/UmbracoJsonModelBinderConvention.cs
#	src/Umbraco.Web.Common/Controllers/RenderController.cs
#	src/Umbraco.Web.Common/Macros/PartialViewMacroPage.cs
#	src/Umbraco.Web.Common/Views/UmbracoViewPage.cs
#	src/Umbraco.Web.UI.NetCore/Views/Partials/blocklist/default.cshtml
#	src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3-fluid.cshtml
#	src/Umbraco.Web.UI.NetCore/Views/Partials/grid/bootstrap3.cshtml
#	src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/embed.cshtml
#	src/Umbraco.Web.UI.NetCore/Views/Partials/grid/editors/macro.cshtml
#	src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs
#	src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs
This commit is contained in:
Mole
2021-02-17 15:35:44 +01:00
42 changed files with 510 additions and 334 deletions

View File

@@ -6,6 +6,7 @@ using Umbraco.Cms.Web.Common.Attributes;
namespace Umbraco.Cms.Web.Common.ApplicationModels
{
// TODO: This should just exist in the back office project
/// <summary>
@@ -13,45 +14,43 @@ namespace Umbraco.Cms.Web.Common.ApplicationModels
/// </summary>
public class BackOfficeApplicationModelProvider : IApplicationModelProvider
{
public BackOfficeApplicationModelProvider(IModelMetadataProvider modelMetadataProvider)
private readonly List<IActionModelConvention> _actionModelConventions = new List<IActionModelConvention>()
{
ActionModelConventions = new List<IActionModelConvention>()
{
new BackOfficeIdentityCultureConvention()
};
}
new BackOfficeIdentityCultureConvention()
};
/// <inheritdoc />
/// <summary>
/// Will execute after <see cref="DefaultApplicationModelProvider"/>
/// </summary>
public int Order => 0;
public List<IActionModelConvention> ActionModelConventions { get; }
/// <inheritdoc/>
public void OnProvidersExecuted(ApplicationModelProviderContext context)
{
}
/// <inheritdoc/>
public void OnProvidersExecuting(ApplicationModelProviderContext context)
{
foreach (var controller in context.Result.Controllers)
foreach (ControllerModel controller in context.Result.Controllers)
{
if (!IsBackOfficeController(controller))
continue;
foreach (var action in controller.Actions)
{
foreach (var convention in ActionModelConventions)
continue;
}
foreach (ActionModel action in controller.Actions)
{
foreach (IActionModelConvention convention in _actionModelConventions)
{
convention.Apply(action);
}
}
}
}
private bool IsBackOfficeController(ControllerModel controller)
=> controller.Attributes.OfType<IsBackOfficeAttribute>().Any();
}
}