/// <summary>
 /// 注册一个流程管理器实例
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public IProcessManager ResgiterProcess(string name)
 {
     if (string.IsNullOrEmpty(name) || piplines.Any(x => name == x.Key))
     {
         throw new EventCoordinatorException($"流程{name}注册失败");
     }
     else
     {
         currentPipline     = new EventProcessManagerPipline(logger);
         currentPipline.Key = name;
     }
     return(this);
 }
        /// <summary>
        /// 获取并开始执行一个流程
        /// </summary>
        /// <typeparam name="TEvent"></typeparam>
        /// <param name="name"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task GetAndRun <TEvent>(string name, TEvent input) where TEvent : EventProcessBase
        {
            var config = piplines.FirstOrDefault(x => x.Key == name);

            if (config != null)
            {
                var instance = new EventProcessManagerPipline(logger, config);
                await instance.Start(input);
            }
            else
            {
                throw new EventCoordinatorException($"没有查询到流程{name}!");
            }
        }
 public EventProcessManagerPipline(ILogger logger, EventProcessManagerPipline pipline)
 {
     this.logger    = logger;
     this.Key       = pipline.Key;
     this.Processes = new ConcurrentQueue <ProcessConfigureBase>();
     foreach (var item in pipline.GetProcessee())
     {
         Processes.Enqueue(item);
     }
     ;
     this.CallbackList = new ConcurrentDictionary <string, ConcurrentStack <ProcessConfigureBase> >();
     foreach (var item in pipline.GetCallbackList())
     {
         var callbacklist  = new List <ProcessConfigureBase>();
         var callbackstack = new ConcurrentStack <ProcessConfigureBase>();
         foreach (var child in item.Value)
         {
             callbacklist.Add(child);
         }
         callbacklist.Reverse();//由于是从栈复制到栈,所以这里需要进行一次反转
         callbacklist.ForEach(x => callbackstack.Push(x));
         CallbackList.TryAdd(item.Key, callbackstack);
     }
 }