Example #1
0
        /// <summary>
        /// 切换流程
        /// </summary>
        /// <param name="type">目标流程</param>
        public void SwitchProcedure(Type type)
        {
            if (Procedures.ContainsKey(type))
            {
                if (CurrentProcedure == Procedures[type])
                {
                    return;
                }

                ProcedureBase lastProcedure = CurrentProcedure;
                ProcedureBase nextProcedure = Procedures[type];
                if (lastProcedure != null)
                {
                    lastProcedure.OnLeave(nextProcedure);
                }
                nextProcedure.OnEnter(lastProcedure);
                CurrentProcedure = nextProcedure;

                AnyProcedureSwitchEvent?.Invoke(lastProcedure, nextProcedure);
            }
            else
            {
                throw new HTFrameworkException(HTFrameworkModule.Procedure, "切换流程失败:不存在流程 " + type.Name + " 或者流程未激活!");
            }
        }
        /// <summary>
        /// 切换流程
        /// </summary>
        /// <param name="type">目标流程</param>
        public void SwitchProcedure(Type type)
        {
            if (_procedureInstances.ContainsKey(type))
            {
                if (_currentProcedure == _procedureInstances[type])
                {
                    return;
                }

                ProcedureBase lastProcedure = _currentProcedure;
                ProcedureBase nextProcedure = _procedureInstances[type];
                if (lastProcedure != null)
                {
                    lastProcedure.OnLeave(nextProcedure);
                }
                nextProcedure.OnEnter(lastProcedure);
                _currentProcedure = nextProcedure;
            }
            else
            {
                throw new HTFrameworkException(HTFrameworkModule.Procedure, "切换流程失败:不存在流程 " + type.Name + " 或者流程未激活!");
            }
        }