コード例 #1
0
ファイル: Pipeline{T}.cs プロジェクト: mzy666888/Simplify
        /// <summary>
        /// Process pipeline stages.
        /// </summary>
        /// <param name="item">The item for execution.</param>
        /// <returns></returns>
        public virtual bool Execute(T item)
        {
            OnPipelineStart?.Invoke(item);

            foreach (var stage in _stages)
            {
                var result = stage.Execute(item);

                OnStageExecuted?.Invoke(stage.GetType(), item, result);

                if (result == false)
                {
                    return(false);
                }
            }

            OnPipelineEnd?.Invoke(item);

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Process pipeline stages.
        /// </summary>
        /// <param name="item">The item for execution.</param>
        /// <returns></returns>
        public bool Execute(T item)
        {
            OnPipelineStart?.Invoke(item);

            foreach (var stage in _stages)
            {
                var result = stage.Execute(item);

                OnStageExecuted?.Invoke(stage.GetType(), item, result);

                if (result)
                {
                    continue;
                }

                ErrorResult = stage.ErrorResult;

                return(false);
            }

            OnPipelineEnd?.Invoke(item);

            return(true);
        }