自定义configSections时,这样的格式如何写?

zhao8848jun 2012-03-20 04:03:42
<outboundRules>
<!--新闻频道-->
<rule name="NEWS_EXCLUSIVEREPORT">
<!--独家报道-->
<match filterByTags="A, Area" pattern="^(.*/)news/list\.aspx\?Id=5360" />
<action type="Rewrite" value="/shtml/news/EXCLUSIVEREPORT" />
</rule>
<rule name="NEWS_STAR">
<!--明星-->
<match filterByTags="A, Area" pattern="^(.*/)news/list\.aspx\?Id=4642" />
<action type="Rewrite" value="/shtml/news/STAR" />
</rule>
</outboundRules>

// 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;
}
}
}
...全文
58 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhao8848jun 2012-07-04
  • 打赏
  • 举报
回复
没人用过这方面吗

62,242

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧