C# 3.0 使用自定义配置读取ConfigurationSection值并表示为域对象(C#3.0)

C# 3.0 使用自定义配置读取ConfigurationSection值并表示为域对象(C#3.0),c#-3.0,C# 3.0,我在app.config文件中有一个部分 <OurType> <sometype typename = "type1" Iscolor="true"/> <sometype typename = "type2" Iscolor="false"/> </Ourtype> 我想做一些像 list obj=ConfigurationManager.GetCollection(Something),它将读取该部分的配置部分,然后填充列表 如何使用自定

我在app.config文件中有一个部分

<OurType>
 <sometype typename = "type1" Iscolor="true"/>
 <sometype typename = "type2" Iscolor="false"/>
</Ourtype>
我想做一些像

list obj=ConfigurationManager.GetCollection(Something)
,它将读取该部分的配置部分,然后填充列表

如何使用自定义配置进行此操作

谢谢


我正在使用C#3.0和dot net framework 3.5,这是最简单的方法吗?在Codeplex上查看Visual Studio 2005和2008的附加模块。它为您提供了一个很好的用户界面,并生成了所有那些棘手的配置类和XML模式,以便在您的配置部分为您启用Visual Studio intellisense—所有这些都非常简洁、方便

看看

如果您想“手工”完成,请务必查看Jon Rista在CodeProject上的.NET 2.0配置上的三部分系列

强烈推荐,写得好,非常有帮助


马克:最简单的方法是什么?在Codeplex上查看Visual Studio 2005和2008的附加模块。它为您提供了一个很好的用户界面,并生成了所有那些棘手的配置类和XML模式,以便在您的配置部分为您启用Visual Studio intellisense—所有这些都非常简洁、方便

看看

如果您想“手工”完成,请务必查看Jon Rista在CodeProject上的.NET 2.0配置上的三部分系列

强烈推荐,写得好,非常有帮助

马克

Class OurType
{

  public string TypeName{get;set;}
  public string IsColor{get;set;}
}