Ejemplo n.º 1
0
        /// <summary>
        /// Creates the state machine.
        /// </summary>
        /// <param name="stateMachineName">Name of the state machine.</param>
        /// <returns>The state machine</returns>
        public IStateMachine CreateStateMachine(string stateMachineName)
        {
            if (string.IsNullOrEmpty(stateMachineName))
            {
                throw new ArgumentNullException("stateMachineName");
            }

            string fileName = UnifyFileName(stateMachineName);

            if (_machineBuilderCache.ContainsKey(fileName) == false)
            {
                _machineBuilderCache[fileName] = _factory.Create <StateMachineBuilder>(fileName);
            }

            StateMachineBuilder stateMachineBuilder = _machineBuilderCache[fileName];

            var machine = new StateMachine {
                Tag = stateMachineName
            };

            stateMachineBuilder.BuildStateMachine(machine);

            return(machine);
        }