使用Enterprise Library中的DAAB来实现对数据库的操作。
配置信息写在配置文件中。
如果我想在配置文件中加入自己定义的信息,应该如何操作?
我现在的操作方法如下:
一.定义一个类,继承自ConfigurationSecion(配置文件中的节) public class CustomSection : ConfigurationSection
    {        public CustomSection()
        {
        }        [ConfigurationProperty("name")]
        public string Name
        {
            get { return (string)this["name"]; }
            set { this["name"] = value; }
        }        [ConfigurationProperty("size")]
        public float Size
        {
            get { return (float)this["size"]; }
            set { this["size"] = value; }
        }        [ConfigurationProperty("style")]
        public int Style
        {
            get { return (int)this["style"]; }
            set { this["style"] = value; }
        }        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Name = {0}; Size = {1}; Style = {2}", Name, Size.ToString(), Style.ToString());
            return sb.ToString();
        }    }
二.在配置文件中添加
 System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel .None);
 CustomSection customSection= new Custom节点Section();
                customSection.Name = "雨人";
                customSection.Size = 10;
                customSection.Style = 199;
                config.Sections.Add("CustomsSection", customSection);
                customSection.SectionInformation.ForceSave = true;
                config.Save(ConfigurationSaveMode.Full);这样做可以将要保存的内容保存到配置文件中。现在的问题是在获取这个添加的内容时如果通过节点名称是没有问题的,如果想获取出全部的节点然后显示到程序中的话就会发现config.Sections()返回的section集合中包含很多不知名的section(当然要取的section包含其中),并且这些section在打开config文件后看不到。
   所以请教对企业库2.0熟悉的朋友指点怎么方便灵活的存取配置文件的自定义信息。

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4825/4825034.xml?temp=.6424982我的开源程序用到了企业库,你可以看下.
      

  2.   

    to:C2K(彩虹在哪里)
    到你的网站去下载了源码。可是速度很慢。
    既然你用到了企业库,能先把我的问题说说吗?
      

  3.   

    企业库2.0 在配置文件中加入自己定义的信息,使用的是.net2.0 的System.Configuration 。
    查看一下.net 2.0 的MSDN
      

  4.   

    这个不关企业库的事,在 。NET2.0下很好解决,看看MSDN吧