public PropertyCollection(string strDefaultSectionName,
                           string strPropertyString,
                           DelimiterFormat format)
 {
     Build(strDefaultSectionName,
           strPropertyString,
           format);
 }
        // 按照类目输出局部字符串
        public string ToString(DelimiterFormat format,
                               string strCategory)
        {
            if (String.IsNullOrEmpty(strCategory))
            {
                strCategory = "*";
            }

            if (strCategory == "*")
            {
                return(this.ToString(format));
            }

            string strResult = "";

            for (int i = 0; i < this.Count; i++)
            {
                // 选择目录
                if (String.Compare(this[i].Name, strCategory, true) != 0)
                {
                    continue;
                }

                string strSection = this[i].ToString();
                if (strSection == "")
                {
                    continue;
                }

                if (strResult != "")
                {
                    if (format == DelimiterFormat.Semicolon)
                    {
                        strResult += ";";
                    }
                    else if (format == DelimiterFormat.CrLf)
                    {
                        strResult += "\r\n";
                    }
                    else if (format == DelimiterFormat.Mix)
                    {
                        strResult += ";\r\n";
                    }
                    else
                    {
                        throw new Exception("不支持的SeperatorFormat类型: " + format.ToString());
                    }
                }

                strResult += strSection;
            }

            return(strResult);
        }
        public void Build(string strDefaultSectionName,
                          string strPropertyString,
                          DelimiterFormat format)
        {
            this.Clear();

            // 根据分号拆分
            string[] sections = null;

            if (format == DelimiterFormat.Semicolon)
            {
                sections = strPropertyString.Split(new char[] { ';' });
            }
            else if (format == DelimiterFormat.CrLf)
            {
                sections = strPropertyString.Replace("\r\n", "\r").Split(new char[] { '\r' });
            }
            else if (format == DelimiterFormat.Mix)
            {
                sections = strPropertyString.Replace("\r\n", "\r").Split(new char[] { '\r', ';' });
            }
            else
            {
                throw new Exception("不支持的SeperatorFormat类型: " + format.ToString());
            }


            for (int i = 0; i < sections.Length; i++)
            {
                string strSection = sections[i].Trim();

                if (String.IsNullOrEmpty(strSection))
                {
                    continue;
                }

                Section section = new Section(strDefaultSectionName, strSection);

                this.Add(section);
            }
        }
        // 输出全部字符串
        public string ToString(DelimiterFormat format)
        {
            string strResult = "";

            for (int i = 0; i < this.Count; i++)
            {
                string strSection = this[i].ToString();
                if (strSection == "")
                {
                    continue;
                }

                if (strResult != "")
                {
                    if (format == DelimiterFormat.Semicolon)
                    {
                        strResult += ";";
                    }
                    else if (format == DelimiterFormat.CrLf)
                    {
                        strResult += "\r\n";
                    }
                    else if (format == DelimiterFormat.Mix)
                    {
                        strResult += ";\r\n";
                    }
                    else
                    {
                        throw new Exception("不支持的SeperatorFormat类型: " + format.ToString());
                    }
                }

                strResult += strSection;
            }

            return(strResult);
        }