我需要在我的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