/// <summary>
        /// Set the param value in the sub section
        /// The sub section will be created if not exist.
        /// </summary>
        /// <param name="sSubSectionName"></param>
        /// <param name="sParamName"></param>
        /// <param name="oValue"></param>
        public void SetParam(string sSubSectionName,
                             string sParamName,
                             object oValue)
        {
            // if section not found create it.
            if (!IsSubSectionExist(sSubSectionName))
            {
                SubSection oSubSection = new SubSection(sSubSectionName);
                oSubSection.AddParam(sParamName, oValue.GetType().ToString(), oValue);

                m_oSubSections[sSubSectionName] = oSubSection;
            }
            else
            {
                SubSection oSection = (SubSection)m_oSubSections[sSubSectionName];

                // find if parameter exists set it's value
                if (oSection.IsParamExist(sParamName))
                {
                    oSection.SetParamValue(sParamName, oValue);
                }
                else                 // create the parameter and set it's value
                {
                    oSection.AddParam(sParamName, oValue.GetType().ToString(), oValue);
                }
            }
        }
        /// <summary>
        /// Add new sub section to the sub sections collection
        /// </summary>
        /// <param name="sSectionName"></param>
        public void CreateSubSection(string sSectionName)
        {
            if (!m_oSubSections.Contains(sSectionName))
            {
                SubSection oSubSection = new SubSection(sSectionName);
                m_oSubSections[sSectionName] = oSubSection;

                m_oSectionsToCreate.Add(sSectionName);
            }
        }
        /// <summary>
        /// Go through all the Sub Sections in memory and
        /// Build the sub sections with all the parameters
        /// as childs elements of the inner xml .
        /// </summary>
        /// <param name="sInnerXML"></param>
        public void BuildSubSectionsElements(XmlDocument oXmlDoc, ref string sInnerXML)
        {
            int i = 0;

            // create new sub sections if needed
            for (i = 0; i < m_oSectionsToCreate.Count; i++)
            {
                CreateSubSectionElement(oXmlDoc, m_oSectionsToCreate[i].ToString());
            }

            // delete the sub sections if needed
            for (i = 0; i < m_oSectionsToDelete.Count; i++)
            {
                DeleteSubSectionElement(oXmlDoc, m_oSectionsToDelete[i].ToString());
            }

            // build all the parameters for the sub section
            SubSection oSection = null;

            foreach (DictionaryEntry sectionEntry in m_oSubSections)
            {
                oSection = (SubSection)sectionEntry.Value;

                // build the parameters of the section
                SubSectionParameter [] oParameters = oSection.Parameters;
                if (oParameters != null)
                {
                    for (i = 0; i < oParameters.Length; i++)
                    {
                        SubSectionParameter oParam = (SubSectionParameter)oParameters.GetValue(i);
                        if (oParam != null)
                        {
                            // build the parameter
                            BuildParam(oXmlDoc,
                                       oSection.Name,
                                       oParam.ParamName,
                                       oParam.ParamValue);
                        }
                    }
                }
            }

            // find the ConfigSection node and update the inner xml

            string  xPath = "SECTION" + "[@" + ATTR_NAME + " = \"" + m_sConfigSectionName + "\"]";
            XmlNode oConfigSectionNode = oXmlDoc.DocumentElement.SelectSingleNode(xPath);

            if (oConfigSectionNode != null)
            {
                // update the inner xml of the parent Config section
                // with the changes of new sub sections
                sInnerXML = oConfigSectionNode.InnerXml.ToString();
            }
        }
        /// <summary>
        /// Get param value according to sub section and param name
        /// </summary>
        /// <param name="sSubSectionName"></param>
        /// <param name="sParamName"></param>
        public object GetParam(string sSubSectionName,
                               string sParamName)
        {
            object oValue = null;

            // check if section exist
            if (IsSubSectionExist(sSubSectionName))
            {
                SubSection oSection = (SubSection)m_oSubSections[sSubSectionName];
                oValue = oSection.GetParamValue(sParamName);
            }

            return(oValue);
        }
        public string[] GetParamsNames(string sSubSectionName)
        {
            if (!IsSubSectionExist(sSubSectionName))
            {
                return(EmptyArrays.StringArray);
            }

            SubSection oSection = (SubSection)m_oSubSections[sSubSectionName];

            string[] ParamNames = new string[oSection.Parameters.Length];

            for (int i = 0; i < ParamNames.Length; i++)
            {
                ParamNames[i] = oSection.Parameters[i].ParamName;
            }

            return(ParamNames);
        }
        public void InitSubSections(XmlDocument oXmlDoc)
        {
            try
            {
                XmlNodeList oSections = null;

                // select all the INISections under the config section name
                // and build the SubSections collection in memory

                string xPath = "SECTION" + "[@" + ATTR_NAME + " = \"" + m_sConfigSectionName + "\"]" + "/" + INI_SECTION;;
                oSections = oXmlDoc.DocumentElement.SelectNodes(xPath);

                if (oSections != null && oSections.Count > 0)
                {
                    m_oSubSections.Clear();

                    string sSectionName = "";

                    for (int i = 0; i < oSections.Count; i++)
                    {
                        XmlNode oSectionNode = oSections[i];
                        if (oSectionNode.Attributes[ATTR_NAME] != null)
                        {
                            sSectionName = oSectionNode.Attributes[ATTR_NAME].Value.ToString();

                            // build the SubSection object with parameters
                            SubSection oSubSection = new SubSection(sSectionName);

                            if (oSectionNode.HasChildNodes)
                            {
                                string sParamName  = "";
                                string sParamType  = "";
                                object oParamValue = null;

                                for (int j = 0; j < oSectionNode.ChildNodes.Count; j++)
                                {
                                    XmlNode oParamNode = oSectionNode.ChildNodes[j];
                                    if (oParamNode.Attributes[ATTR_NAME] != null)
                                    {
                                        sParamName = oParamNode.Attributes[ATTR_NAME].Value.ToString();
                                    }
                                    if (oParamNode.Attributes[ATTR_TYPE] != null)
                                    {
                                        sParamType = oParamNode.Attributes[ATTR_TYPE].Value.ToString();
                                    }

                                    if (StringUtil.IsStringInitialized(sParamName) &&
                                        StringUtil.IsStringInitialized(sParamType))
                                    {
                                        Type oParamType = Type.GetType(sParamType);
                                        oParamValue = Convert.ChangeType(oParamNode.InnerText.ToString(), oParamType);

                                        // add the parameter to the sub section
                                        oSubSection.AddParam(sParamName, sParamType, oParamValue);
                                    }
                                }
                            }

                            // save the current sub section
                            m_oSubSections[sSectionName] = oSubSection;
                        }
                    }
                }
            }                           // of try

            catch (Exception e)
            {
                // write error to Log File.
                Log.WriteError("IniXmlElements.InitSubSections  initialization failed  , Details :  {0}", e.Message);
                throw new TisException(
                          e,
                          "IniXmlElements.InitSubSections initialization failed , Details :  {0}", e.Message);
            }
        }