<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Net;
using System.Net.Mime;
using System.Web.Mvc;
using System.Globalization;
using System.Web.Mvc.Async;
using NServiceMVC.Formats;

namespace NServiceMVC.WebStack
{
    class ActionInvoker : ControllerActionInvoker
    {
        public ActionInvoker(ServiceController controller)
            : base()
        {
            this.Controller = controller;
        }

        protected ServiceController Controller { get; set; }

       // public string ViewName { get; set; }

        //public static Func<object, ActionResult> DefaultViewFunction { get; set; }

        private static readonly Type ActionResultType = typeof(ActionResult);

        protected override ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue)
        {
            // Inspect controller method's declared return type. If it's ActionResult or a derived type we bypass the NServiceMVC serialization logic.
            Type actionMethodReturnType = null;
            if (actionDescriptor is ReflectedActionDescriptor)
                actionMethodReturnType = ((ReflectedActionDescriptor)actionDescriptor).MethodInfo.ReturnType;
            else if (actionDescriptor is ReflectedAsyncActionDescriptor)
                actionMethodReturnType = ((ReflectedAsyncActionDescriptor)actionDescriptor).CompletedMethodInfo.ReturnType;

            if (actionMethodReturnType != null)
            {
                // Check if controller action method declares an ActionResult type then bypass the NServiceMVC logic and pass the result.
                if (ActionResultType.IsAssignableFrom(actionMethodReturnType))
                {
                    return (ActionResult)actionReturnValue;
                }
            }

            // bulk of this from ResourcesOverMvc.Web.Mvc.MultipleRepresentationsAttribute.OnActionExecuted()

            //// Create a list of the charsets the client is willing to support in order of preference
            //// (adding the encoding the client used in the request as the last alternative)<commit_msg>ActionInvoker public, takes dynamic controller<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Net;
using System.Net.Mime;
using System.Web.Mvc;
using System.Globalization;
using System.Web.Mvc.Async;
using NServiceMVC.Formats;

namespace NServiceMVC.WebStack
{
    public class ActionInvoker : ControllerActionInvoker
    {
        public ActionInvoker(dynamic controller)
            : base()
        {
            this.Controller = controller;
        }

        protected dynamic Controller { get; set; }

       // public string ViewName { get; set; }

        //public static Func<object, ActionResult> DefaultViewFunction { get; set; }

        private static readonly Type ActionResultType = typeof(ActionResult);

        protected override ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue)
        {
            // Inspect controller method's declared return type. If it's ActionResult or a derived type we bypass the NServiceMVC serialization logic.
            Type actionMethodReturnType = null;
            if (actionDescriptor is ReflectedActionDescriptor)
                actionMethodReturnType = ((ReflectedActionDescriptor)actionDescriptor).MethodInfo.ReturnType;
            else if (actionDescriptor is ReflectedAsyncActionDescriptor)
                actionMethodReturnType = ((ReflectedAsyncActionDescriptor)actionDescriptor).CompletedMethodInfo.ReturnType;

            if (actionMethodReturnType != null)
            {
                // Check if controller action method declares an ActionResult type then bypass the NServiceMVC logic and pass the result.
                if (ActionResultType.IsAssignableFrom(actionMethodReturnType))
                {
                    return (ActionResult)actionReturnValue;
                }
            }

            // bulk of this from ResourcesOverMvc.Web.Mvc.MultipleRepresentationsAttribute.OnActionExecuted()

            //// Create a list of the charsets the client is willing to support in order of preference
            //// (adding the encoding the client used in the request as the last alternative)
{'fraction_non_alphanumeric': 0.061659192825112105, 'fraction_numerical': 0.0, 'mean_word_length': 2.812820512820513, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '400552', 'n_tokens_mistral': 1031, 'n_tokens_neox': 993, 'n_words': 322}