Ejemplo n.º 1
0
        public static ActionInfo BuildActionFromDefinition(ActionLinkDefinition definition, FormContext context)
        {
            string url = definition.Action;

            if (definition.ActionType == ActionType.Function)
            {
                url = "";
            }

            if (definition.ActionType != ActionType.Page)
            {
                url = GetUrlFromActionType(definition.ActionType);
            }

            url = string.Format("{0}{1}", context.Context.AppRoot, url);

            var q = context.RequestQuery.Clone();

            if (definition.QueryParam != null && definition.QueryParam.Count > 0)
            {
                q = new RequestQueryString();
                foreach (var p in definition.QueryParam)
                {
                    q.Add(p.Name, ValueResolver.ResolveValue(context, p.Value).ToString());
                }
            }

            var actionI = new ActionInfo(url, q, definition.ActionId);

            actionI.Title         = definition.Text;
            actionI.ActionType    = definition.ActionType;
            actionI.ExecutionType = definition.ExecType;

            if (definition.ActionType == ActionType.Function)
            {
                actionI.AddAttribute("Function", definition.Action);
                actionI.ExecutionType = ActionExecutionType.Custom;
            }

            return(actionI);
        }