public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            IDataFormatter formatter = DataFormatters.GetFormatter(filterContext);

            if (formatter != null)
            {
                filterContext.Controller.ViewBag.DataFormatter = formatter;
                filterContext.Controller.ViewBag.AddIncludes   = formatter.AddIncludes;
            }
            base.OnActionExecuting(filterContext);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            IDataFormatter formatter = DataFormatters.GetFormatter(filterContext);

            if (formatter != null)
            {
                filterContext.Controller.ViewData[DxaViewDataItems.DisableOutputCache] = true;
                filterContext.Controller.ViewData[DxaViewDataItems.DataFormatter]      = formatter;
                filterContext.Controller.ViewData[DxaViewDataItems.AddIncludes]        = formatter.AddIncludes;
            }
            else
            {
                filterContext.Controller.ViewData[DxaViewDataItems.DisableOutputCache] = false;
            }
            base.OnActionExecuting(filterContext);
        }
Beispiel #3
0
        public virtual double Score(ControllerContext controllerContext)
        {
            double        score      = 0.0;
            List <string> validTypes = DataFormatters.GetValidTypes(controllerContext, _mediaTypes);

            if (validTypes.Any())
            {
                foreach (string type in validTypes)
                {
                    double thisScore = DataFormatters.GetScoreFromAcceptString(type);
                    if (thisScore > score)
                    {
                        score = thisScore;
                    }
                }
            }
            return(score);
        }