コード例 #1
0
        /// <summary>
        /// Creates a new node with the specified task name.
        /// </summary>
        /// <param name="taskName">Name of the task.</param>
        /// <param name="action">The action.</param>
        /// <returns></returns>
        public TaskNode <T> Create(string taskName, Func <T, bool> action)
        {
            var node = new TaskNode <T>()
            {
                TaskName = taskName,
                Action   = action,
                Parent   = this,
            };

            _nodes.Add(node);
            if (!_runnings.ContainsKey(node.TaskName))
            {
                _runnings.Add(node.TaskName, new Count());
            }

            return(node);
        }
コード例 #2
0
        protected internal virtual void Event(EventKind kind, TaskNode <T> taskNode, Exception exception = null)
        {
            string msg = string.Empty;

            if (exception != null)
            {
                msg = $"{taskNode.TaskName} is {kind} at {DateTime.Now}. {exception.Message}";
            }
            else
            {
                msg = $"{taskNode.TaskName} is {kind} at {DateTime.Now}";
            }

#if DEBUG
            Debug.WriteLine(msg);
#endif
            Trace.WriteLine(msg);
        }
コード例 #3
0
ファイル: TaskNode.cs プロジェクト: Black-Beard-Sdk/Planifier
 /// <summary>
 /// Continues with the specified node
 /// </summary>
 /// <param name="node">The node.</param>
 /// <param name="stopIfFailed">if set to <c>true</c> [stop if the current node is failed].</param>
 /// <returns></returns>
 public TaskNode <T> ContinueWith(TaskNode <T> node, bool stopIfFailed = true)
 {
     node._guards.Add(new Guard(this, stopIfFailed));
     return(node);
 }
コード例 #4
0
ファイル: TaskNode.cs プロジェクト: Black-Beard-Sdk/Planifier
        public TaskNode <T> ContinueWith(string taskName, bool stopIfFailed = true)
        {
            TaskNode <T> node = Parent.Get(taskName) ?? throw new Exception($"task node {taskName} can't be resolved");

            return(ContinueWith(node, stopIfFailed));
        }
コード例 #5
0
ファイル: TaskNode.cs プロジェクト: Black-Beard-Sdk/Planifier
 public Guard(TaskNode <T> taskNode, bool stopIfFailed)
 {
     _taskNode     = taskNode;
     _stopIfFailed = stopIfFailed;
 }
コード例 #6
0
 internal void Stop(TaskNode <T> task)
 {
     _runnings[task.TaskName].Decrement();
 }
コード例 #7
0
 internal void Start(TaskNode <T> task)
 {
     _runnings[task.TaskName].Increment();
 }