我需要在 app.config 中存储 2 个设置部分,并根据初始化类时传递的值,我将加载其中一个设置部分。
这是我理想中需要实现的目标:
班级
Public Class SiteSettings
Sub New(ByVal Id As Integer)
If Id = 1 Then
'Load in group1 settings.
'Ideally the settings will be available as properties
Else
'Load in group2 settings
End If
End Sub
...
End Class
代码
Dim objSettings = New SiteSettings(Id)
'just to demo what I'm trying to achieve
response.Write(objSettings.setting1)
应用程序配置
<siteSettings>
<section name="group1">
<setting1 value="abc" />
</section>
<section name="group2">
<setting1 value="xyz" />
</section>
</siteSettings>