コード例 #1
0
        /// <summary>
        /// Gets the configuration of the task.
        /// </summary>
        //public TaskConfig Configuration
        //{
        //    get
        //    {
        //        if (m_Config == null)
        //        {
        //            m_Config = ServiceHost.GetActivityConfiguration(String.Empty, this.GetType()) as TaskConfig;
        //            //if (m_Config == null)
        //            //    throw new InvalidOperationException(String.Format("Task '{0}' has no defined configuration of type 'TaskConfig'. Found config entry with type '{1}'", this.GetType().Name, m_Config.GetType().Name));

        //            return m_Config;
        //        }

        //        return m_Config;
        //    }
        //}

        /// <summary>
        /// Get configuration for Task in specified orchestrationName
        /// </summary>
        /// <param name="orchestrationName"></param>
        /// <returns></returns>
        public TaskConfig GetConfiguration(object orchestrationName)
        {
            string name = orchestrationName.ToString();

            if (m_Config == null)
            {
                m_Config = ServiceHost.GetActivityConfiguration(name, this.GetType()) as TaskConfig;
                //if (m_Config == null)
                //    throw new InvalidOperationException(String.Format("Task '{0}' has no defined configuration of type 'TaskConfig'. Found config entry with type '{1}'", this.GetType().Name, m_Config.GetType().Name));

                // if still null, set to empty instance of TaskConfig
                if (m_Config == null)
                {
                    m_Config = new TaskConfig();
                }

                return(m_Config);
            }

            return(m_Config);
        }