62,047
社区成员
发帖
与我相关
我的任务
分享
// Define a custom section containing a simple element and a collection of the same element.
// It uses two custom types: UrlsCollection and UrlsConfigElement.
public class UrlsConfig
{
public static UrlsSection GetConfig()
{
return (UrlsSection)System.Configuration.ConfigurationManager.GetSection("CustomConfiguration");
}
}
public class UrlsSection : ConfigurationSection
{
[ConfigurationProperty("urls",IsDefaultCollection = false)]
public UrlsCollection Urls
{
get
{
return (UrlsCollection)this["urls"];
}
}
}
//
//中间如何衔接……?
//
// Define the UrlConfigElementMatch.
public class UrlConfigElementMatch : ConfigurationElement
{
[ConfigurationProperty("filterByTags", IsRequired = true)]
public string filterByTags
{
get
{
return (string)this["filterByTags"];
}
set
{
this["filterByTags"] = value;
}
}
[ConfigurationProperty("pattern", IsRequired = true)]
public string pattern
{
get
{
return (string)this["pattern"];
}
set
{
this["pattern"] = value;
}
}
}
// Define the UrlConfigElementaction.
public class UrlConfigElementAction : ConfigurationElement
{
[ConfigurationProperty("type", IsRequired = true)]
public string type
{
get
{
return (string)this["type"];
}
set
{
this["type"] = value;
}
}
[ConfigurationProperty("value", IsRequired = true)]
public string value
{
get
{
return (string)this["value"];
}
set
{
this["value"] = value;
}
}
}