public WorkflowAttributeCollection(MetadataAttributeCollection collection)
     : base(StringComparer.InvariantCultureIgnoreCase)
 {
     foreach (var kvp in collection.Attributes)
     {
         Add(kvp.Key, kvp.Value);
     }
 }
        /// <summary>
        /// Returns resolved Attribute Collection set based on the request scope.
        /// </summary>
        /// <param name="WfId"></param>
        /// <param name="StepId"></param>
        /// <param name="ConstId"></param>
        /// <param name="RunId"></param>
        /// <returns></returns>
        public WorkflowAttributeCollection WorkflowAttributeCollectionGet(int WfId, int StepId, int ConstId, int RunId)
        {
            WorkflowAttributeCollection attributes = new WorkflowAttributeCollection();
            string xml_string;

            using (SqlConnection cn = new SqlConnection())
            {
                cn.ConnectionString = _connection_string;
                try
                {
                    cn.Open();

                    string cmd_text = String.Format(WORKFLOW_ATTRIBUTE_QUERY
                                                    , WfId
                                                    , (StepId == 0) ? "null" : StepId.ToString()
                                                    , (ConstId == 0) ? "null" : ConstId.ToString()
                                                    , RunId,
                                                    ((_debug) ? 1 : 0));
                    using (SqlCommand cmd = new SqlCommand(cmd_text, cn))
                    {
                        cmd.CommandTimeout = COMMAND_TIMEOUT;
                        cmd.CommandType    = CommandType.Text;
                        var xml = cmd.ExecuteScalar();
                        xml_string = xml.ToString();
                    }

                    attributes = new WorkflowAttributeCollection(MetadataAttributeCollection.DeSerializefromXml(xml_string));
                }
                catch (Exception ex)
                {
                    throw (ex);
                }
                finally
                {
                    if (cn.State != ConnectionState.Closed)
                    {
                        cn.Close();
                    }
                }
            }

            return(attributes);
        }
        public static MetadataAttributeCollection DeSerializefromXml(string XMLString)
        {
            MetadataAttributeCollection attributes = new MetadataAttributeCollection();

            //XMLValidator validator = new XMLValidator();
            //if (validator.ValidatingProcess(Resources.ETLControllerXSD, XMLString))
            //{

            try
            {
                XmlSerializer wfser = new XmlSerializer(typeof(MetadataAttributeCollection));
                attributes = (MetadataAttributeCollection)wfser.Deserialize(new StringReader(XMLString));
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            //}
            //else
            //{
            //    throw new Exception("Workflow Xml was not in the correct format");
            //}
            return(attributes);
        }