56b7f8d98b
Added internal setting for global settings to return an MVC area string based on the umbraco path. Added a ton of extension methods from v5 that are used in much of the MVC engines. Added UmbracoHelper methods for MVC rendering including Field so that we can render the correct RTE field markup when the RTE contains a macro, will add extension methods for the @CurrentPage dynamic object to do the same to make it consistent.
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System.Web.Mvc;
|
|
|
|
namespace Umbraco.Web
|
|
{
|
|
internal static class ViewDataContainerExtensions
|
|
{
|
|
private class ViewDataContainer : IViewDataContainer
|
|
{
|
|
public ViewDataContainer()
|
|
{
|
|
ViewData = new ViewDataDictionary();
|
|
}
|
|
public ViewDataDictionary ViewData { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new IViewDataContainer but with a filtered ModelState
|
|
/// </summary>
|
|
/// <param name="container"></param>
|
|
/// <param name="prefix"></param>
|
|
/// <returns></returns>
|
|
public static IViewDataContainer FilterContainer(this IViewDataContainer container, string prefix)
|
|
{
|
|
var newContainer = new ViewDataContainer();
|
|
newContainer.ViewData.ModelState.Merge(container.ViewData.ModelState, prefix);
|
|
return newContainer;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a new IViewContainer based on the current one but supplies a different model to the ViewData
|
|
/// </summary>
|
|
/// <param name="container"></param>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public static IViewDataContainer CopyWithModel(this IViewDataContainer container, object model)
|
|
{
|
|
return new ViewDataContainer
|
|
{
|
|
ViewData = new ViewDataDictionary(container.ViewData)
|
|
{
|
|
Model = model
|
|
}
|
|
};
|
|
}
|
|
|
|
}
|
|
} |