public BaseActionMetaData(BaseActionCommand <TBusiness> action)
 {
     ActionName    = action.GetType().Name;
     MethodName    = ActionName.Substring(0, ActionName.Length - 6);
     Method        = typeof(TBusiness).GetMethod(MethodName);
     BusinessLogic = action.BusinessLogic;
 }
Пример #2
0
        public ActionDescriptor(MethodInfo methodInfo, RouteInfo routeInfo)
        {
            MethodInfo = methodInfo;
            RouteInfo  = routeInfo;

            ActionName = methodInfo.Name;
            if (ActionName.EndsWith("Async"))
            {
                ActionName = ActionName.Substring(0, ActionName.Length - "Async".Length);
            }

            ControllerName = methodInfo.DeclaringType.Name;
            ControllerName = ControllerName.Substring(0, ControllerName.Length - "Controller".Length);
        }
        public virtual object Execute(StateMachineActionContext context)
        {
            if (!ActionName.Contains("::"))
            {
                return(StateMachine.ActionTaskManager.ExecuteTask(ActionName, context));
            }

            //An alternate task execute syntax is being supported now that will
            //allow any method on a named task to be invoked using the ::, following the syntax
            //TaskName::MethodName

            string taskName   = ActionName.Substring(0, ActionName.IndexOf("::"));
            string methodName = ActionName.Substring(ActionName.IndexOf("::") + 2);

            ITask task = StateMachine.ActionTaskManager.CreateTask(taskName);

            if (task != null)
            {
                var wrapper = new CustomExecMethodTaskWrapper(task, methodName);
                return(wrapper.Execute(StateMachine.ActionTaskManager.CreateTaskContext(context)));
            }

            throw new ArgumentException("A task with the name " + taskName + " could not be found.");
        }