Files
Umbraco-CMS/src/Umbraco.Web/ViewContextExtensions.cs
Shannon Deminick 56b7f8d98b Got .Field method for MVC working and have macro's rendering inside of RTE in MVC.
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.
2012-09-05 09:35:24 +07:00

34 lines
936 B
C#

using System.Web.Mvc;
namespace Umbraco.Web
{
internal static class ViewContextExtensions
{
/// <summary>
/// Creates a new ViewContext from an existing one but specifies a new Model for the ViewData
/// </summary>
/// <param name="vc"></param>
/// <param name="model"></param>
/// <returns></returns>
public static ViewContext CopyWithModel(this ViewContext vc, object model)
{
return new ViewContext
{
Controller = vc.Controller,
HttpContext = vc.HttpContext,
RequestContext = vc.RequestContext,
RouteData = vc.RouteData,
TempData = vc.TempData,
View = vc.View,
ViewData = new ViewDataDictionary(vc)
{
Model = model
},
FormContext = vc.FormContext,
ClientValidationEnabled = vc.ClientValidationEnabled,
UnobtrusiveJavaScriptEnabled = vc.UnobtrusiveJavaScriptEnabled,
Writer = vc.Writer
};
}
}
}