Azavea.Open.Common.Config.ParseConfigXml C# (CSharp) Method

ParseConfigXml() private method

Reads the XML and populates the various attributes based on it (lists of params, dictionaries of params, etc).
private ParseConfigXml ( ) : void
return void
        private void ParseConfigXml()
        {
            try
            {
                XmlNodeList nodeList = ConfigXmlDoc.GetElementsByTagName("component");
                foreach (XmlNode node in nodeList)
                {
                    string componentName = node.Attributes["name"].Value;

                    // Save the entire XML section for the GetConfigXml method
                    _outerXmlByComponent[componentName] = node.OuterXml;
                    _innerXmlByComponent[componentName] = node.InnerXml;

                    if (_paramsByComponent.ContainsKey(componentName))
                    {
                        throw new LoggingException("Component '" + componentName +
                                                   "' is defined twice in this config file!");
                    }
                    IDictionary<string, string> componentParams = MakeParameterCollection();
                    _paramsByComponent[componentName] = componentParams;
                    IList<KeyValuePair<string, string>> orderedComponentParams =
                        new List<KeyValuePair<string, string>>();
                    _orderedParamsByComponent[componentName] = orderedComponentParams;
                    // Now save all the individual parameters.
                    foreach (XmlNode paramNode in node.ChildNodes)
                    {
                        // Ignore any child nodes that aren't parameters.
                        if (StringHelper.SafeEquals("parameter", paramNode.Name))
                        {
                            string paramName = paramNode.Attributes["name"].Value;
                            if (componentParams.ContainsKey(paramName))
                            {
                                throw new LoggingException("Component '" + componentName +
                                                           "' has parameter '" + paramName + "' defined twice!");
                            }
                            XmlAttribute valueAttr = paramNode.Attributes["value"];
                            string paramValue;
                            if (valueAttr != null)
                            {
                                paramValue = valueAttr.Value;
                            }
                            else
                            {
                                XmlNodeList paramKids = paramNode.ChildNodes;
                                if (paramKids.Count == 1)
                                {
                                    XmlNode paramKid = paramKids[0];
                                    if (paramKid.NodeType == XmlNodeType.Text || paramKid.NodeType == XmlNodeType.CDATA)
                                    {
                                        paramValue = paramKid.Value;
                                    }
                                    else
                                    {
                                        throw new LoggingException("Component '" + componentName +
                                                                   "', parameter '" + paramName +
                                                                   "', has invalid nested XML ('" + paramNode.InnerText +
                                                                   "').  Only text is supported inside a parameter tag.");
                                    }
                                }
                                else
                                {
                                    throw new LoggingException("Component '" + componentName +
                                                               "', parameter '" + paramName +
                                                               "', has invalid nested XML ('" + paramNode.InnerText +
                                                               "').  Only text is supported inside a parameter tag.");
                                }
                            }
                            componentParams[paramName] = paramValue;
                            orderedComponentParams.Add(new KeyValuePair<string, string>(paramName, paramValue));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ReThrowException("Error parsing config XML.",
                    new object[] { Application, ConfigFile }, e);
            }
        }