Files
Umbraco-CMS/src/Umbraco.Web/Mvc/RenderModelBinder.cs
Shannon Deminick d4d4272b1b Moved RenderModel to Models namespace. Created new base UmbracoViewPage to use for umbraco partial views, etc... and renamed
RenderViewPage to UmbracoTemplatePage which now inherits from UmbracoViewPage. Added NiceUrl and NiceUrlWithDomain as extension
methods to IPublishedContent.
2012-10-24 09:59:23 +05:00

31 lines
942 B
C#

using System.Web.Mvc;
using Umbraco.Web.Models;
namespace Umbraco.Web.Mvc
{
public class RenderModelBinder : IModelBinder
{
/// <summary>
/// Binds the model to a value by using the specified controller context and binding context.
/// </summary>
/// <returns>
/// The bound value.
/// </returns>
/// <param name="controllerContext">The controller context.</param><param name="bindingContext">The binding context.</param>
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var requestMatchesType = typeof(RenderModel) == bindingContext.ModelType;
if (requestMatchesType)
{
//get the model from the route data
if (!controllerContext.RouteData.DataTokens.ContainsKey("umbraco"))
return null;
var model = controllerContext.RouteData.DataTokens["umbraco"] as RenderModel;
return model;
}
return null;
}
}
}