Files
Umbraco-CMS/src/Umbraco.Web/Mvc/ViewContextExtensions.cs
Shannon Deminick 8fb159ddc2 Changes IThumbnailProvider to exist under Umbraco.Core.Media instead of just Umbraco.Core.
Moves many of the MVC extension methods into the Umbraco.Web.Mvc namespace and tidies up a few other
class's namespaces
2012-09-29 08:07:00 +07:00

34 lines
940 B
C#

using System.Web.Mvc;
namespace Umbraco.Web.Mvc
{
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
};
}
}
}