void ActionUrl(EncodedTextWriter output, Context context, Arguments arguments)
        {
            if (arguments.Length < 1 || arguments.Length > 3)
            {
                throw new ArgumentOutOfRangeException(nameof(arguments));
            }

            IDictionary <string, object> routeValues = null;
            string controller = null;
            string action     = (arguments[0] as Page)?.ActionName ?? (string)arguments[0];

            if (arguments.Length >= 2) // [actionName, controllerName/routeValues ]
            {
                if (arguments[1] is IDictionary <string, object> r)
                {
                    routeValues = r;
                }
                else if (arguments[1] is string s)
                {
                    controller = s;
                }
                else if (arguments[1] is Page v)
                {
                    controller = v.ControllerName;
                }
                else
                {
                    throw new Exception("ActionUrl: Invalid parameter 1");
                }
            }
            if (arguments.Length == 3) // [actionName, controllerName, routeValues]
            {
                routeValues = (IDictionary <string, object>)arguments[2];
            }

            if (controller == null)
            {
                controller = context["ControllerName"] as string;
            }

            string url = BaseUrl + controller;

            if (!string.IsNullOrEmpty(action))
            {
                url += "/" + action;
            }

            output.WriteSafeString(AddQueryString(url, routeValues));
        }
        void MenuItemActionLink(EncodedTextWriter output, Context context, Arguments arguments)
        {
            var dict = arguments[0] as IDictionary <string, object> ?? new Dictionary <string, object>()
            {
                ["controller"] = arguments[0]
            };

            string classes = "item";

            if (dict["controller"].Equals(context["ControllerName"]))
            {
                classes += " active";
            }

            string url   = BaseUrl + dict["controller"];
            string title = dict.GetValue("title", dict["controller"]) as string;

            //string title = HtmlEncode(value);

            output.WriteSafeString($@"<a href=""{url}"" class=""{classes}"">{title}</a>");
        }
        void RenderJobDataMapValue(EncodedTextWriter output, Context context, Arguments arguments)
        {
            var item = (JobDataMapItem)arguments[1];

            output.WriteSafeString(item.SelectedType.RenderView((Services)arguments[0], item.Value));
        }
 void Json(EncodedTextWriter output, Context context, Arguments arguments)
 {
     output.WriteSafeString(Newtonsoft.Json.JsonConvert.SerializeObject(arguments[0]));
 }
Exemple #5
0
 private void RawOutput(EncodedTextWriter output, Context context, Arguments arguments)
 {
     output.WriteSafeString($"{context["Message"]}");
 }