/// <summary>
        ///根据文件名读取工作流定义对象
        /// </summary>
        /// <param name="app">The app.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <returns></returns>
        private WorkFlowDefine ReadFromFile(WorkflowApplication app, string fileName)
        {
            StateMachineWorkflow stateMachine  = new StateMachineWorkflow();
            XmlSerializer        xmlSerializer = new XmlSerializer(typeof(StateMachineWorkflow));

            using (XmlReader reader = XmlReader.Create(fileName))
            {
                stateMachine = (StateMachineWorkflow)xmlSerializer.Deserialize(reader);
            }
            string errorMsg;

            if (!stateMachine.Validate(out errorMsg))
            {
                throw new ApplicationException(errorMsg);
            }

            //设置其应用程序对象
            stateMachine.Application = app;
            return(stateMachine);
        }
        /// <summary>
        /// Gets all workflow.
        /// </summary>
        /// <returns></returns>
        public WorkFlowDefine[] GetAllWorkflow(string applicationName)
        {
            WorkflowConfig config = GetConfig();

            if (config == null)
            {
                throw new ArgumentException("workflow config xml file is miss or wrong format");
            }
            List <WorkFlowDefine> workflows   = new List <WorkFlowDefine>();
            WorkflowApplication   application = config.Get(applicationName);

            if (application == null)
            {
                throw new NullReferenceException(string.Format("{0} cannot found", applicationName));
            }
            foreach (WorkflowDefineConfig one in application.Defines)
            {
                if (one.Enabled)
                {
                    workflows.Add(GetWorkflowDefine(one.Name));
                }
            }
            return(workflows.ToArray());
        }