我需要在我的Web.config文件中创建嵌套节,我找不到符合我的要求的任何示例。web.config中的嵌套节
<IPTests>
<Environment environment="DEV">
<Machine machine="Web01">
<SiteIP site="Sitecore" ip="10.10.2.191">
</SiteIP>
</Machine>
</Environemnt>
</IPTests>
这是用于“健康检查”为不同的应用程序/网站。我需要检查所有不同网站使用的资源。我已经使用DNS完成了这项工作,但是现在我需要在我们的不同服务器的不同环境中执行此操作,方法是使用IP地址访问不同的服务器。
任何帮助将是伟大的!
这是我到目前为止。
public class IPTests : ConfigurationSectionGroup
{
[ConfigurationProperty("codeEnvironment")]
public CodeEnvironmentSection CodeEnvironment
{
get { return (CodeEnvironmentSection)base.Sections["codeEnvironment"]; }
}
}
public class CodeEnvironmentSection : ConfigurationSection
{
[ConfigurationProperty("environemnt")]
public ValueElement To
{
get { return (ValueElement)base["environemnt"]; }
}
}
public class MachineSection : ConfigurationSection
{
[ConfigurationProperty("machine")]
public ValueElement To
{
get { return (ValueElement)base["machine"]; }
}
}
public class SiteIPSection : ConfigurationSection
{
[ConfigurationProperty("site")]
public ValueElement To
{
get { return (ValueElement)base["site"]; }
}
[ConfigurationProperty("ip")]
public ValueElement To
{
get { return (ValueElement)base["ip"]; }
}
}
public class ValueElement : ConfigurationElement
{
[ConfigurationProperty("value")]
public string Value
{
get { return (string)base["value"]; }
set { base["value"] = value; }
}
}
[你有什么试过](http://mattgemmell.com/2008/12/08/what-have-you-tried/)? – 2012-07-10 18:09:51
我一直在尝试使用这个前面的例子:http://stackoverflow.com/questions/5027284/nested-configuration-section-app-config但是我不能让它工作因为我的多个巢 – Staleyr 2012-07-10 18:17:15