示例#1
0
        public static void LoadFrom(string[] assemblyDirs, string scriptfilename, out List <ActionElement> elements, out List <ActionElementLink> links)
        {
            elements = null;
            links    = null;
            using (TaskScriptParser parser = new TaskScriptParser(assemblyDirs))
            {
                ArgAutoBingdingEnvironment env = null;
                parser.FromTaskScriptFile(scriptfilename, out env);
                if (env == null || env.ActionArgSettings == null || env.ActionArgSettings.Length == 0)
                {
                    throw new Exception("脚本文件\"" + scriptfilename + "\"为空。");
                }
                Dictionary <int, ActionElement>            eles     = new Dictionary <int, ActionElement>();
                Dictionary <LinkObject, ActionElementLink> linkObjs = new Dictionary <LinkObject, ActionElementLink>();
                foreach (ActionArgCollection action in env.ActionArgSettings)
                {
                    ActionElement ele = GetActionElement(action);
                    eles.Add(action.Id, ele);
                    //
                    foreach (ActionArg arg in action.ActionArgs)
                    {
                        switch (arg.ArgType)
                        {
                        case enumArgType.Value:
                            break;

                        case enumArgType.Var:
                            break;

                        case enumArgType.Ref:
                            LinkObject lnkObj = GetLinkObject(linkObjs, action.Id, arg.RefActionId);
                            if (lnkObj != null)     //添加一条函数映射关系
                            {
                            }
                            else
                            {
                                ActionElement     refActionElement = GetActionElement(arg.RefActionId, eles);
                                ActionElementLink actionLnk        = new ActionElementLink(refActionElement, ele);
                                linkObjs.Add(new LinkObject(action.Id, arg.RefActionId), actionLnk);
                            }
                            break;
                        }
                    }
                }
                elements = new List <ActionElement>(eles.Values.ToArray());
                links    = new List <ActionElementLink>(linkObjs.Values.ToArray());
            }
        }
示例#2
0
 public ITask AddTask(string scriptfilename, IVarProvider varProvider, bool isLoopExecute)
 {
     using (TaskScriptParser parser = new TaskScriptParser(_assemblySearchDirs))
     {
         ArgAutoBingdingEnvironment env = null;
         ITask task = parser.FromTaskScriptFile(scriptfilename, out env);
         if (task != null)
         {
             (task as Task).SetArgAutoBingdingEnvironment(env);
             (task as Task).IsLoopExecute = isLoopExecute;
             (task as Task).SetVarProvider(varProvider);
             (task as Task).SetLog(_log);
             (task as Task).SetTracker(_tracker);
             if (_taskes == null)
             {
                 _taskes = new List <ITask>();
             }
             _taskes.Add(task);
             return(task);
         }
     }
     return(null);
 }