<commit_before>using System;
using System.Globalization;
using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Web.Models;

namespace Umbraco.Web.Mvc
{
	public class RenderModelBinder : IModelBinder, IModelBinderProvider
    {
		/// <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)
		{
            object model;
            if (controllerContext.RouteData.DataTokens.TryGetValue("umbraco", out model) == false)
                return null;

            var culture = UmbracoContext.Current.PublishedContentRequest.Culture;
            return BindModel(model, bindingContext.ModelType, culture);
        }

        // source is the model that we have
        // modelType is the type of the model that we need to bind to
        // culture is the CultureInfo that we have, used by RenderModel
        //
        // create a model object of the modelType by mapping:
        // { RenderModel, RenderModel<TContent>, IPublishedContent }
        // to
        // { RenderModel, RenderModel<TContent>, IPublishedContent }<commit_msg>Fixes another reported bug for U4-7950<commit_after>using System;
using System.Globalization;
using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Web.Models;

namespace Umbraco.Web.Mvc
{
	public class RenderModelBinder : IModelBinder, IModelBinderProvider
    {
		/// <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)
		{
            object model;
            if (controllerContext.RouteData.DataTokens.TryGetValue("umbraco", out model) == false)
                return null;

            var culture = CultureInfo.CurrentCulture;
            // bind the model (use context culture as default, if available)
            if (UmbracoContext.Current != null 
                && UmbracoContext.Current.PublishedContentRequest != null
                && UmbracoContext.Current.PublishedContentRequest.Culture != null)
                culture = UmbracoContext.Current.PublishedContentRequest.Culture;

            return BindModel(model, bindingContext.ModelType, culture);
        }

        // source is the model that we have
        // modelType is the type of the model that we need to bind to
        // culture is the CultureInfo that we have, used by RenderModel
        //
        // create a model object of the modelType by mapping:
        // { RenderModel, RenderModel<TContent>, IPublishedContent }
        // to
        // { RenderModel, RenderModel<TContent>, IPublishedContent }
{'fraction_non_alphanumeric': 0.092534504391468, 'fraction_numerical': 0.0015683814303638645, 'mean_word_length': 2.769503546099291, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4639826', 'n_tokens_mistral': 848, 'n_tokens_neox': 825, 'n_words': 256}